We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 43451
    • 5 Posts
    Hi

    My main experience with CMS's is Umbraco and Sitecore (.NET).

    I just installed MODX yesterday and played around with it.

    I would like to have a master template with the basic layout for the page and then another template which inherits from the master template which is specific to the actual page and injects kode/html into a containers on the master (like Umbraco). It seems to me that in MODX there can only be ONE template per page (one layer, no inheritance), so if I want to use same layout but want to have some other content at some layout position then I would have to duplicate my layout HTML into a new template.
    In other words in MODX it is my undertanding is that the template is not just for layout but also for content, which I don't like. Content should be injected into the template.

    I have googled like crazy but not found anything except, some old posts with people trying to do all sorts of hacks. Am I missing something? [ed. note: barryslisk last edited this post 13 years, 6 months ago.]
      • 42046
      • 436 Posts
      Different elements in the same template depending upon which container it's used in?
        • 40076
        • 6 Posts
        It sounds like what you want are chunks which are basically like partial templates. For example you could make a header or sidebar chunk and then call that in each template that requires it with [[$header]] or [[$sidebar]].
          • 43451
          • 5 Posts
          Quote from: rory_g at Apr 21, 2013, 05:23 AM
          It sounds like what you want are chunks which are basically like partial templates. For example you could make a header or sidebar chunk and then call that in each template that requires it with [[$header]] or [[$sidebar]].

          But if I wanted chunk A in left column on Page A and chunk B in left column on Page B then I would have to make two templates right? Because those chunks are called from the template? Not injected into the template from the document/resource level.
            • 43451
            • 5 Posts
            Quote from: absent42 at Apr 21, 2013, 05:12 AM
            Different elements in the same template depending upon which container it's used in?

            Different content at various places in template based on individual document.
              • 3749
              • 24,544 Posts
              Quote from: barryslisk at Apr 21, 2013, 12:44 PM

              But if I wanted chunk A in left column on Page A and chunk B in left column on Page B then I would have to make two templates right? Because those chunks are called from the template? Not injected into the template from the document/resource level.

              Not necessarily. There are a number of ways to do what you want in MODX. For example, you can create a Template Variable (TV) that holds the chunk tag. Template Variables can have a different value for each page. They can also inherit values from ancestors in the tree.

              Suppose your chunks are called 'SomeChunk' and 'SomeOtherChunk' and your Template Variable is called 'WhichChunk'.

              On Page A, the value of the TV is [[$SomeChunk]].
              On Page B, the value is [[$SomeOtherChunk]].

              In your Template, you place this tag where the chunk goes: [[*WhichChunk]]

              On page A it will show SomeChunk there and on Page B it will show SomeOtherChunk.

                Did I help you? Buy me a beer
                Get my Book: MODX:The Official Guide
                MODX info for everyone: http://bobsguides.com/modx.html
                My MODX Extras
                Bob's Guides is now hosted at A2 MODX Hosting
                • 43451
                • 5 Posts
                Quote from: BobRay at Apr 21, 2013, 01:14 PM
                Quote from: barryslisk at Apr 21, 2013, 12:44 PM

                But if I wanted chunk A in left column on Page A and chunk B in left column on Page B then I would have to make two templates right? Because those chunks are called from the template? Not injected into the template from the document/resource level.

                Not necessarily. There are a number of ways to do what you want in MODX. For example, you can create a Template Variable (TV) that holds the chunk tag. Template Variables can have a different value for each page. They can also inherit values from ancestors in the tree.

                Suppose your chunks are called 'SomeChunk' and 'SomeOtherChunk' and your Template Variable is called 'WhichChunk'.

                On Page A, the value of the TV is [[$SomeChunk]].
                On Page B, the value is [[$SomeOtherChunk]].

                In your Template, you place this tag where the chunk goes: [[*WhichChunk]]

                On page A it will show SomeChunk there and on Page B it will show SomeOtherChunk.


                Hmm...yes that could work. I'll try that! Thanks a lot for your time.
                  • 4172
                  • 5,888 Posts
                  you can also create listbox-multiple-TVs with some chunks as input-options like:

                  chunkA==[$chunkA]]||chunkB==[$chunkB]]


                  Than its possible to select, which chunks to show on your page.

                  Another option is to use a MIGX-TV to select and sort chunks on pages.
                  With MIGX its also possible to give each chunk different contents.
                  You could handle all chunks for one page in one MIGX-TV with a selector for the different possible positions. Or you can create multiple MIGX-TVs, one for each position.

                  There are endless Options in MODX. Creative Freedom.
                    -------------------------------

                    you can buy me a beer, if you like MIGX

                    http://webcmsolutions.de/migx.html

                    Thanks!
                    • 42046
                    • 436 Posts
                    Depending on your site structure you could also use conditionals within a single template to include different chunks or modify the output of TVs with output modifiers based upon where within the site the page is appearing.
                      • 28042 ☆ A M B ☆
                      • 24,524 Posts
                      For years I amused myself by using one template for entire sites, using TVs, snippets (mostly for loading .js only as needed), conditionals and different .css files using TVs to set the .css file to use. Then it just became more convenient to have three or four templates (especially since Form Customization for Revo isn't anywhere near as flexible as ManagerManager is for Evo). Any parts that need to be the same for multiple templates, such as the masthead and menu and the footer, are broken out into chunks. I still make a careful consideration of the page requirements to minimize the number of templates, though. I once was given a site that had over 60 templates, which I converted to use one. A further port of the same site to use Revo is using four templates.
                        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