We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 6531
    • 154 Posts
    Is there a quick way to insert a chunk conditionally based on a checkbox TV?
    Or do I need to write a snippet for that?

    Given a checkbox TV ’xxx’, I would like to put in my template something like:
    [[*xxx:true=[[$chunk1]] ]]
    [[*xxx:false=[[$chunk2]] ]]
    


    I tried
    [[*xxx:true=`yes`]

    but that did not work at all...
      • 11316
      • 81 Posts
      I don’t know if this helps but I will give it a go! Try starting with a drop down menu tv first.

      Create 2 chunks
      chunk1
      chunk2

      create a Template Variable
      name = tvSidebarChk

      Input Type:drop down / checkbox
      Input Option values: Chunk 1==[[$chunk1?]]||Chunk 1==[[$chunk2?]]

      Edit your template and put this.

      <div id="sidebar">[[*tvSidebarChk?]]</div>
      When editing your documents - you can select which chunk you want to show on your template.
        • 6531
        • 154 Posts
        interesting! what does the ’?’ before the ’]]’ do ??
          • 11316
          • 81 Posts
          The syntax has changed slightly since Evo but it’s basically the same principal.

          Direct from the source, I believe you can use it as a string for further development - you can try leaving it off to test.

          http://rtfm.modx.com/display/revolution20/Tag+Syntax
          ? (optional; indicates beginning of property string)