We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 22393
    • 6 Posts
    hi,
    i’m having trouble grasping the concept of when i should be using either a module, snippet or plugin.
    i haven’t found the documentation very helpful in learning this (possibly my own fault).


    In my previous post (http://modxcms.com/forums/index.php/topic,26980.0.html), i was asking about creating a basic product catalog with seo-enabled product details page (fridge-kleenmaid-details.php)

    - do you use a module solely to edit the products in the backend.
    - do you use a snippet to show the list of products in frontend
    - a plugin to recognise the URL (fridge-kleenmaid-details.php) and show the appropriate product details page with a snippet?

    i’m struggling to recognise when to use the different functions of modx for a practical application.

    does that make sense?

    thank you for your wisdom in advance!
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      A module extends the Manager with your custom functionality. No need to hack the Manager core files to add a new bit of database management, or an interface for an external mailing list script, for example.

      A snippet parses PHP code for the front-end (similar to the <?php ... ?> tags in plain files).

      A plugin interrupts the current processing (whether it’s the document parser generating a page, or some other manager function such as creating a user or editing a document). They are triggered by specifically coded "event traps" in the processing php code. For example, the document parser has several of these, like
              // invoke OnPageNotFound event
              $this->invokeEvent('OnPageNotFound');
      

      So a plugin would use the OnPageNotFound event to "plug in" its own code at this point in the process.
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 867
        • 241 Posts
        This is a very simple way of explaining things. Should be put on the wiki and translated. Maybe it is already somewhe in the faq, i haven’t look at it for long.