<?php
$tv = $modx->getTemplateVar('ShowSubbox');
$set = $tv['value'];
if ($set == "yes") {
$output = '{{subbox}}';
return $output;
}
?>
Very clever! I didn’t think of that the first time I thought through it. Now that you’ve set my mind in the right direction though, I would simplify the snippet even more to detect if the TV has content, and then insert the chunk if it does. This eliminates the need to create an extra TV to show/hide the box. But then again, this also might be handy....
I would do the following:
1. Create a Chunk "subbox" with the formatting like you have in the code example.
2. Create a TV from the type "Radio Options" with yes||no values. (To switch the box on or off) Name it something like "ShowSubbox"
Very clever! I didn’t think of that the first time I thought through it. Now that you’ve set my mind in the right direction though, I would simplify the snippet even more to detect if the TV has content, and then insert the chunk if it does. This eliminates the need to create an extra TV to show/hide the box. But then again, this also might be handy....
you could achieve the same with PHx
[*ShowSubbox:is=`yes`:then=`{{subbox}}`*]
[*ShowSubbox:is=`yes`:then=`{{subbox}}`*]I think you could do this with the TV Conditional snippet if you don’t want to use PHx.