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,
No conditionals needed.
you can setup a listbox-TV named section with inputoptions like
and a default-value of
and have
-
☆ A M B ☆
- 3,141 Posts
Quote from: romainfallet at Nov 13, 2015, 04:11 PMYou 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/
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 AMNo conditionals needed.
you can setup a listbox-TV named section with inputoptions like
and a default-value of
and have
Everything I know I learned on the internet. Saved me thousands in College tuition,
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.