We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 9995
    • 1,613 Posts
    Is this possible with revolution?
    To use several id's with different outputs in 1 call?

    Like:

    When id=1 then=pizza or id=2 then=hotdog or id=22 then=dog    else=beer 

      Evolution user, I like the back-end speed and simplicity smiley
      • 4172
      • 5,888 Posts
      try this one:

      <?php
      
      //[[caseChunk? &subject=`[[*id]]` &case1=`1:@CODE:Pizza` &case2=`2:@CODE:Hotdog` &case3=`22:@CODE:Dog` &default=`@CODE:Beer`]]
      
      foreach ($scriptProperties as $property => $case){
          $case = explode (':',$case);
          if ($property == 'default'){
              $default = $case[0] == '@CODE' ? $case[1] : $modx->getChunk($case[0],$scriptProperties);     
          }elseif (count($case)>1){
              if ($subject == $case[0]){
                  return $case[1] == '@CODE' ? $case[2] : $modx->getChunk($case[1],$scriptProperties);
              }
          }
      }
      
      return $default;
      


      call it this way:

      [[caseChunk? 
      &subject=`[[*id]]` 
      &case1=`1:@CODE:Pizza` 
      &case2=`2:@CODE:Hotdog` 
      &case3=`22:@CODE:Dog` 
      &default=`@CODE:Beer`
      ]]
      


      [ed. note: Bruno17 last edited this post 14 years, 6 months ago.]
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 19369
        • 1,098 Posts
        There is also the Switch Snippet:
        [[!Switch?
            &get=`[[*id]]`
            &c1=`1` &do1=`Pizza time!`
            &c2=`2` &do2=`Hotdog`
            &c3=`22` &do3=`Dog`
            &default=`Beer`
          ]]  
          • 9995
          • 1,613 Posts
          Thankz!! Works great, also with calling chunks

          (still a Rev rookie) [ed. note: fourroses666 last edited this post 14 years, 6 months ago.]
            Evolution user, I like the back-end speed and simplicity smiley