I am looking for a simple way to be able to turn off sections within one of my page templates, and was hoping someone could give me some advice. Let me explain.
I have a template that has a section at the bottom of it for a customer quote, but not all the pages will include this section. I am looking to add a toggle into the page instance (backend) so that I can turn off the section when it is not being used. I currently am using a tv that adds a class to the element if I don’t want it to appear (display:none stylie).
If anyone could help me to find a way that the section is not included, instead of hiding it, when the toggle is selected it would be much appreciated.
I am just trying to make sure that there is nothing being pulled in that would cause any issues with users using screen-reading software etc. that would still pick up the hidden code.
There might be a different way of doing this of course, but I thought this way would be cleaner.
Rather than the snippet, a simple output filter will also work in this case. Assuming the TV is named ShowQuote and the actual quote is in a CustomerQuote chunk like Bob suggested, you can use something like this:
[[*ShowQuote:notempty=`[[$CustomerQuote]]`]]
Or with the mosquite syntax to make sure the chunk is not processed unless it has to be:
When you do it in this way or with Bob’s snippet, there will not be anything hidden in the page markup that screenreaders can pick up. I do think screen readers are good at ignoring things that are display: none;, too, but might as well take it out of the markup completely.
I am making the TV radio buttons with ‘Yes’ and ‘No’ (but you could use anything that outputs those options). With a little modification it should them allow for you to add other options in if you want to have a selection of different sections to choose from, but also have it hidden as well.