We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 23006
    • 6 Posts
    I am trying to build a site and will have different pages that will need different chunks and/or snippets on them. How can I do this without making separate themes for each one.

    Thanks!
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      That’s what Template Variables (TVs) are for.

      http://www.modxcms.com/template-variables.html
        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
        • 23006
        • 6 Posts
        Are there any tutorials or other resources that will explain this a bit better than that link?
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          Well, in a nutshell, you create a TV, give it an input type (what will be seen when editing a document) and a default value. Check the box for the template you want it to be used with. Now, every document using that template will have another field (what you assigned it as the input type, for example you’ll get another Rich Text field if you specified that input type). So you can edit this for every document, and you can put the TV tag ( [*tvName*] ) wherever you like, in your template or in your document content.

          I tend to put a TV in my sidebar:
          <div id="leftSidebar">[*leftSide*]</div>

          I use a "binding", @INHERIT, for my default content, and make the input type a textarea. Now, I can edit that for my subheading container documents, and all of their children will inherit that value, so I can have a different sidebar for each section of my site. In the textarea field for each parent document, I can put HTML code and chunks and snippet calls, so my sidebar can be completely customized with menus or whatever I want for each section.

          The best way to get to understand the full power and flexibility of TVs is to play around with making up a few and using them. Just make sure that you check the box for the template you want to use them with.

          Of course, TVs are a lot more flexible than that. For example, you can give it in input type of "image", and each document using the assigned template will have an image input field. If you also specify an output "widget" of image, you’ll get the proper image tags output to your page.

            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
            • 23006
            • 6 Posts
            Thanks!!!