We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 23944
    • 5 Posts
    Hey all – just a quick (and most likely) a very simple answer to this one, but is there an easy way to code conditional statements within templates/chunks to include or exclude other chunks based on a document information such as ID?

    I have kludged this temporarily by using a TV, but ideally it should be a condition within the template code as opposed to an option for every page as it is created. The code itself is a chunk with a Wayfinder call displaying all immediate child documents of the current document, except I do not want it to be included on the root document (ID#1...so, "IF NOT(ID==1)") as this would just duplicate the “main menu” entries. This should by it’s nature be simple? I would normally use the search facility or RTFM, but answers don’t appear to be forthcoming when searching for “if” ;-)
      • 4172
      • 5,888 Posts
      you can have a radio-option-TV for example with input-option-values:

      show submenu=={{submenu}}||hide submenu=={{nothing}}


      and default-value:
      {{submenu}}


      so you have only to check the ’hide submenu’ option, where you don_t want to show this chunk.

      Alternativ you can install phx-plugin and use it like that:

      [*id:is=`1`:then=`{{submenu}}`*]
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 23944
        • 5 Posts
        Fantastic, thank you!

        That makes perfectly obvious sense to have the default as "showing" given that only the root and other very specific pages will not feature the child docs code. I’ve decided to go down the TV route on the basis that it is pragmatic and better suits my level of ModX usage. PHx would spoil me at this stage, but i’ll sure implement it in that way once I am at that stage learning PHx and can learn by example wink