We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 38740
    • 45 Posts
    Hi,
    i have this code to format output to my page:

    [[*ColCnt:is=`3`:then=`three columns`:else=`four columns`]]


    I need to have more conditions, something like :

    [[*ColCnt:is=`3`:then=`three columns`:is=`4`:then=`four columns`:is=`5`:then=`five columns`]]


    Can this be done somehow?
    The SELECT-modifier is not dokumented but can it be used?
    Or do i need to make a custom output modifyer?

    [ed. note: johnjohn22 last edited this post 14 years ago.]
      ____________________________________________________
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      I suspect in this case you would do better with a snippet with a switch structure.
        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
        • 38740
        • 45 Posts
        Thx Susan, will do!
          ____________________________________________________
          • 3749
          • 24,544 Posts
          Yes, a snippet will be *much* faster. Something like this:

          [[!Columns? &colCount=`[[*ColCnt]]` ]]


          <?php 
          /* Columns snippet */
          
          switch ($scriptProperties['colCount']) {
                case "1": $output = "one";  
                    break;
                case "2": $output = 'two';
                    break;  
                case "3": $output =  "three";  
                    break;
                /* etc. */
                default:
                     $output = 'not set';
          }
          
          return $output . ' columns';
            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