We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 19507
    • 3 Posts
    How can i use a template in a snippet ?

    I want to use a template and fill it with content from the snippet code
      • 10487 MODX Staff
      • 1,535 Posts
      I’m not really sure what you’re specifically trying to do without more information but you should consider setting placeholders in your snippet and then putting the placeholder in your template where the various content needs to go.

      Use the following code to set the placeholder in your snippet code (first parameter is the placeholder name, second is the output you want to assign to that placeholder - obviously change to placeholder name and data to your needs) :
      $modx->setPlaceholder('myPlaceholder', $myContent);

      Call your snippet right at the top of the template. Then, in your template, use the following to define where that placeholder data gets inserted into the template:
      [+myPlaceholder+]

        Garry Nutting
        Senior Developer
        MODX, LLC

        Email: [email protected]
        Twitter: @garryn
        Web: modx.com