Search code examples
if-statementmodxmodx-revolution

How can I use multiple operands in an if condition (ModX)


I am using the if-extra for ModX. Is it possible to use mutliple operands, meaning write this code in a shorter way:

  [[!If?
       &subject=`[[!getUrlParam? &name=`id`]]`
       &operator=`EQ`
       &operand=`1`
       &then=`do something`
    ]]


[[!If?
   &subject=`[[!getUrlParam? &name=`id`]]`
   &operator=`EQ`
   &operand=`2`
   &then=`do something`
]]


[[!If?
   &subject=`[[!getUrlParam? &name=`id`]]`
   &operator=`EQ`
   &operand=`3`
   &then=`do something`
]]

Couldn't find a way to do it.


Solution

  • I could work with this solution:

     [[If?
           &subject=`[[!getUrlParam? &name=`id`]]`
           &operator=`inarray`
           &operand=`1,2,3`
           &then=`do something`
        ]]