We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 39025
    • 21 Posts
    I want to wrap a chunk, nested inside another chunk, basically a side bar, with an if statement to check for a page or document name.

    If is this document, show that side bar, if is that document show that side bar, etc.

    100% visual designer here so sorry and thanks in advance.

    Carl
      • 22019
      • 390 Posts
      In Revo you can either use the If extra or an output modifier:

      In your template:

      [[*id:is=`resource id`:then=`[[$chunk1]]`:else=`[[$chunk2]]`]]

        Writer > E-consultant > MODx developer || Salesforce || modx 2.x || PHP 5.2.13 || MySQL client 5.0.86
        • 39025
        • 21 Posts
        Awesome, thank you.

        What if I wanted to check for multiple id's like an elseif?
          • 3109 ☆ A M B ☆
          • 894 Posts
          You can use or with output modifiers as well

          
          [[*id:eq=`resource id`:or:eq=`resource 2 id`:then=``:else=``]] 
          
          


          You can add more or's to this as well just be careful since output modifiers can cause performance issues.
            Benjamin Marte
            Interactive Media Developer
            Follow Me on Twitter | Visit my site | Learn MODX
            • 4172
            • 5,888 Posts
            you can also create a checkbox-TV with all possible chunks for your sidebar with input-options:

            Chunk A==[[$chunk_a]]||Chunk B==[[$chunk_b]]||Chunk C==[[$chunk_c]]||Chunk D==[[$chunk_d]]


            and put this TV-tag into your chunk/template

            Than you need just do check the checkboxes to add chunks to your sidebar.
              -------------------------------

              you can buy me a beer, if you like MIGX

              http://webcmsolutions.de/migx.html

              Thanks!
              • 3749
              • 24,544 Posts
              You can also create a pretty simple snippet to grab the chunks, which would be faster:

              I'm assuming that you only want one chunk in the sidebar, but this could be modified to get multiple chunks:

              [[!GetSidebarChunk? &pageId=`[[*id]]` ]]



              <?php
              /* GetSidebarChunk snippet */
              /* returns the contents of the appropriate chunk based on the page ID */
              
              $output = "";
              switch ($scriptProperties['pageId']) {
              
                    case 12:
                    case 14:
                        $output = $modx->getChunk('SomeChunk');
                        break;
              
                    case 23:
                        $output = $modx->getChunk('SomeOtherChunk');
                        break;
              
                    default:
                        $output = $modx->getChunk('DefaultChunk');
                        break;
              }
              
              return $output;
              



              ---------------------------------------------------------------------------------------------------------------
              PLEASE, PLEASE specify the version of MODX you are using . . . PLEASE!
              MODX info for everyone: http://bobsguides.com/modx.html
                Did I help you? Buy me a beer
                Get my Book: MODX:The Official Guide
                MODX info for everyone: http://bobsguides.com/modx.html
                My MODX Extras
                Bob's Guides is now hosted at A2 MODX Hosting
                • 39025
                • 21 Posts
                Thanks everyone.