We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 2396
    • 101 Posts
    I'd like a page's editor to be able to turn on or off certain elements (chunks) in separate areas of a page depending on the content on the page. I know I can use a single-select listbox TV to switch on/off individual chunks like:
    No Content==[[$empty]]||Image==[[$image]]||Caption==[[$caption]]||Credit==[[$credit]]

    and I can see that I can insert multiple chunks together like:
    Full content==[[$image]][[$caption]][[$credit]]||Part content==[[$image]][[$caption]]

    but is it possible to use a TV to insert multiple chunks in different areas of the page, with blocks of code in between?
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      It may be possible to do so using output modifiers
      Full content==full||Part content==part

      Then in the places where you want the chunks
      [[[[*contentTV:is=`full`:or:is=`part`:then=`$image`]]]]
      ...
      [[[[*contentTV:is=`full`:or:is=`part`:then=`$caption`]]]]
      ...
      [[[[*contentTV:is=`full`:then=`$credit`]]]]
      Repeat as required.
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 2396
        • 101 Posts
        Thankyou so so much, and for being so quick! It's not the first time your MODX knowledge has helped me out. This does seem to work, so I'm using it to build customised pages which are basically like:
        Australia==AU||England==EN||United States==US

        to insert customised content in between fixed content:
        [[[[*:is=`AU`:then=`$australiaImage`]]]][[[[*regionPicker:is=`EN`:then=`$englandImage`]]]][[[[*regionPicker:is=`US`:then=`$australiaImage`]]]]

        with more content in between the sections and then
        [[[[*:is=`AU`:then=`$australiaCaption`]]]][[[[*regionPicker:is=`EN`:then=`$englandCaption`]]]][[[[*regionPicker:is=`US`:then=`$australiaCaption`]]]]

        I love MODX. This is a very flexible but simple technique that opens up some new possibilities for me with how I design sites - do you see anything wrong with this? I wondered how hard it might hit the server if it was more complex like used to insert multiple snippets? [ed. note: atype last edited this post 13 years ago.]
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          If these are custom snippets, I'd be inclined to use one snippet with properties. However, if they are MODx extras snippets, then I think this would be acceptable. Just remember to have the modified tag's output be the desired snippet! Have you read Jason's post explaining why?
            Studying MODX in the desert - http://sottwell.com
            Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
            Join the Slack Community - http://modx.org
            • 4172
            • 5,888 Posts
            I think you would be better with something like that:

            [[$[[*regionPicker]]Image]]
            
            [[$[[*regionPicker]]Caption]]
              -------------------------------

              you can buy me a beer, if you like MIGX

              http://webcmsolutions.de/migx.html

              Thanks!
              • 2396
              • 101 Posts
              Quote from: sottwell at Oct 17, 2013, 01:14 AM
              If these are custom snippets, I'd be inclined to use one snippet with properties. However, if they are MODx extras snippets, then I think this would be acceptable. Just remember to have the modified tag's output be the desired snippet! Have you read Jason's post explaining why?

              I tried to look it up just now, do you mean this one :http://modx.com/blog/2012/09/14/tags-as-the-result-or-how-conditionals-are-like-mosquitoes/

              I also saw several posts on his website that I will need to go back and read once I've met my deadline - launch tomorrow...
                • 2396
                • 101 Posts
                Quote from: Bruno17 at Oct 17, 2013, 02:11 AM
                I think you would be better with something like that:

                [[$[[*regionPicker]]Image]]
                
                [[$[[*regionPicker]]Caption]]

                I just had a 'Doh' moment when I read this Bruno17. It's so brilliantly simple I hadn't thought it could be so easy. But it is. Occam's razor all over again.

                I have used your solution in the end as it is so efficient but also think I've got a use for Sue's answer as it seems to me the 'or' aspect will be very useful in other cases. Thank you both!