We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 21496
    • 225 Posts
    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"

    3. Create a snippet that’s checking if the value of that TV is set to yes/no.

    <?php
    
    $tv = $modx->getTemplateVar('ShowSubbox');
    $set = $tv['value'];
    
    if ($set == "yes") {
    	$output = '{{subbox}}';
    	return $output;
    }
    ?>
    


    4. In your template, place [[SnippetName]] to call the snippet where you want to display your sidebar box.

    Is that what you want to do?
      René
      • 28150
      • 155 Posts
      This definitely sounds like it may do the trick!

      I will try it out later and report back. Thanks!
        • 27376
        • 576 Posts
        Quote from: nightsignals at Oct 08, 2007, 06:40 AM

        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....

        Of course, with MODx there a several solutions to a problem wink
          • 21496
          • 225 Posts
          Quote from: sirlancelot at Oct 15, 2007, 12:34 PM

          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 will definitely need that function of auto detecting if the TV has content or not in the future. If you write it, please post it here. However I guess it comes to full power if that approach is combined with the possibility to switch it on or off, as on certain pages - in my case contact and links - I never want to show that box.

          And yeah, the flexibility and elegance of MODx is great - even if I just scratched the surface. I already feel more and more restricted when I have to work with Textpattern or ExpressionEngine.
            René
            • 11975
            • 2,542 Posts
            Hi,

            you could achieve the same with PHx

            [*ShowSubbox:is=`yes`:then=`{{subbox}}`*]

            :-)
              Made with MODx : [url=http://www.copadel.com]copadel, fruits et l
              • 7455
              • 2,204 Posts
              Yup I use phX all the time for this.
                follow me on twitter: @dimmy01
                • 21496
                • 225 Posts
                Quote from: heliotrope at Oct 15, 2007, 01:30 PM

                you could achieve the same with PHx

                [*ShowSubbox:is=`yes`:then=`{{subbox}}`*]

                Oh - thanks, that’s great. The only issue is that PHx doesn’t play well together with eForm.
                  René
                  • 7455
                  • 2,204 Posts
                  There are lots of options and fixes for that floating around the board so that phX and eform work nice togetter
                    follow me on twitter: @dimmy01
                    • 7231
                    • 4,205 Posts
                    [*ShowSubbox:is=`yes`:then=`{{subbox}}`*]
                    I think you could do this with the TV Conditional snippet if you don’t want to use PHx.

                      [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

                      Something is happening here, but you don&#39;t know what it is.
                      Do you, Mr. Jones? - [bob dylan]