We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 30716
    • 1 Posts
    Help! Can someone help a newbie with what is a basic task?

    How and where do you insert snippets?

    Do you put the code snippet into the page where you want it to appear?

    For example I want to use eForm so do I tried putting this code into a page:

    [[runSnippet(’eForm)]]

    Could you MODx developers please include this in the basic documentation and FAQ pages - it seems to be the basis of how to configure MODx and something I’m sure all newbies would need to know.
      • 30223
      • 1,010 Posts
      Do you put the code snippet into the page where you want it to appear?

      Basically yes, you place snippets in the content of the page where you want the output to appear ( or in the page template, for instance with wayfinder).

      Snippets are placed in the document in either of two forms (which you can read in the documentation on this site), cached or uncached. i.e. [[snippetName]] or [!snippetName!].


      In your case you need to use the unchached form. Somthing like this:

      [!eForm ...lots of parameters... !]


      If you read the eForm documentation you’ll find some detailed examples (see the assets/snippets/eform/docs/ directory). That should help you along....
        • 25663 MODX Staff
        • 12,272 Posts
        Here’s an example real-world eForm call. Note a few things are really important, and apply to most snippet calls:

        1) Since it’s a form that needs further processing, it’s got to be called uncached: [! (vs. the regular [[)

        2) Since it needs parameters, you put a question mark immediately after the snippet name: [!eform? ...

        3) The parameters are wrapped in backtick marks. On US English Keyboards that’s is likely the key immediately to the left of the top-row 1-key: ` (it’s NOT a single-quote mark)

        [!eForm?formid=`echoform` &tpl=`form.cart.payment` &noemail=`1` &gotoid=`181`!]

          Ryan Thrash, MODX Co-Founder
          Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me