【问题标题】:How can I use multiple operands in an if condition (ModX)如何在 if 条件中使用多个操作数(ModX)
【发布时间】:2016-01-30 12:44:26
【问题描述】:

我正在为 ModX 使用 if-extra。是否可以使用多个操作数,这意味着以更短的方式编写此代码:

  [[!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`
]]

找不到办法。

【问题讨论】:

    标签: if-statement modx modx-revolution


    【解决方案1】:

    额外尝试https://modx.com/extras/package/switch

    [[!switch? 
       &get=`[[!getUrlParam? &name=`id`]]` 
       &c1=`1`
       &do1=`do something1`
       &c2=`2`
       &do2=`do something2`
       &c3=`3`
       &do3=`do something3`
       &default=`default value`
    ]]
    

    【讨论】:

      【解决方案2】:

      我可以使用这个解决方案:

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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-03-08
        • 1970-01-01
        • 2018-05-10
        • 1970-01-01
        • 2019-05-17
        相关资源
        最近更新 更多