We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 36573
    • 173 Posts
    I have a site with multiple sections that need different headers. My base templates are made up of primarily chucks. so, I have a chunk called [[$Hdr-base]] that is the default. I'd like to apply the template and have the header chunk change based on the parent or ultimate parent if it goes down a few levels.

    Most of the information I found on this is for Evo.
      Everything I know I learned on the internet. Saved me thousands in College tuition,
      • 47212
      • 40 Posts
      You can use the UltimateParent snippet with an output filter to do this. I think this works but I didn't test it :
      [[!UltimateParent? &id=`[[*id]]`:is=`1`:then=`[[$Hdr-base]]`:else=`[[$Hdr-new]]`]]
        • 4172
        • 5,888 Posts
        No conditionals needed.
        you can setup a listbox-TV named section with inputoptions like
        base||news||other

        and a default-value of
        @INHERIT


        and have
        [[$Hdr-[[*section]]]]

          -------------------------------

          you can buy me a beer, if you like MIGX

          http://webcmsolutions.de/migx.html

          Thanks!
          • 18373 ☆ A M B ☆
          • 3,141 Posts
          Quote from: romainfallet at Nov 13, 2015, 04:11 PM
          You can use the UltimateParent snippet with an output filter to do this. I think this works but I didn't test it :
          [[!UltimateParent? &id=`[[*id]]`:is=`1`:then=`[[$Hdr-base]]`:else=`[[$Hdr-new]]`]]

          You'll want to make sure that is called cached (the ultimate parent doesn't change from one request to the next), and this is a great example where the mosquito trick is useful for performance. Finally, the order of the parameters and output filters needs to be switched around.

          [[$[[UltimateParent:is=`1`:then=`Hdr-base`:else=`Hdr-new`? &id=`[[*id]]`]]]]


          For more information about how that works, have a look at this blog post: http://modx.com/blog/2012/09/14/tags-as-the-result-or-how-conditionals-are-like-mosquitoes/
            Mark Hamstra • Developer spending his days working on Premium Extras and a MODX Site Dashboard with the ability to remotely upgrade MODX and extras to make the MODX world a little better.

            Tweet me @mark_hamstra, check my infrequent blog at markhamstra.com, my slightly more frequent ramblings at MODX.today or see code at Github.
            • 36573
            • 173 Posts
            I like this idea Bruno. Could this be done in a snippet so I could put it in the template rather than a TV?


            Quote from: Bruno17 at Nov 14, 2015, 12:06 AM
            No conditionals needed.
            you can setup a listbox-TV named section with inputoptions like
            base||news||other

            and a default-value of
            @INHERIT


            and have
            [[$Hdr-[[*section]]]]

              Everything I know I learned on the internet. Saved me thousands in College tuition,
              • 4172
              • 5,888 Posts
              sure, could also be done with a snippet.
              But you'l need something to get the chunkname from, if you haven't a TV
              You could use the pagetitle or alias of the ultimate-parent as part of the chunkname
              Or just use the id of the ultimateparent as part of the chunkname.
                -------------------------------

                you can buy me a beer, if you like MIGX

                http://webcmsolutions.de/migx.html

                Thanks!
                • 47212
                • 40 Posts
                Quote from: markh at Nov 15, 2015, 02:20 PM
                Quote from: romainfallet at Nov 13, 2015, 04:11 PM
                You can use the UltimateParent snippet with an output filter to do this. I think this works but I didn't test it :
                [[!UltimateParent? &id=`[[*id]]`:is=`1`:then=`[[$Hdr-base]]`:else=`[[$Hdr-new]]`]]

                You'll want to make sure that is called cached (the ultimate parent doesn't change from one request to the next), and this is a great example where the mosquito trick is useful for performance. Finally, the order of the parameters and output filters needs to be switched around.

                [[$[[UltimateParent:is=`1`:then=`Hdr-base`:else=`Hdr-new`? &id=`[[*id]]`]]]]


                For more information about how that works, have a look at this blog post: http://modx.com/blog/2012/09/14/tags-as-the-result-or-how-conditionals-are-like-mosquitoes/

                Hum, yeah, very good to know. Thanks.