IF条件TypoScript for cObject

时间:2013-08-29 12:10:46

标签: typo3 typoscript

我里面有HMENU和TMENU。对于TMENU.NO.after属性,我需要根据当前页面uid以动态方式分配cObject?

代码:

#Privatni podmeni
lib.meni= HMENU
lib.meni.special = list
lib.meni.special.value = 5395, 5396, 5397, 5398
lib.meni.wrap = <ul id="menu" style="display:none;">|</ul>
lib.meni.1 = TMENU

    lib.meni.1{
      expAll = 1
      NO {

       allWrap = <li>|</li>
       ATagParams.insertData = 1
       ATagParams = class="drop _{field:uid}"
       after.cObject < temp.meni5
      }
    }

我需要伪代码:

IF field:uid = 5240
   after.cObject < temp.meni5
IF field:uid = 5241
   after.cObject < temp.meni6
IF field:uid = 5342
   after.cObject < temp.meni7

我该怎么做?

2 个答案:

答案 0 :(得分:1)

您可以使用COA cObject并将其部分设置:

lib.meni.1.NO.after.cObject = COA
lib.meni.1.NO.after.cObject {
  10 < temp.meni5
  10.if.equals.field = uid
  10.if.value = 5240

  20 < temp.meni6
  20.if.equals.field = uid
  20.if.value = 5241

  30 < temp.meni7
  30.if.equals.field = uid
  30.if.value = 5342
}

但是,如果 temp.meni5 temp.meni6 temp.meni7 中的对象支持stdWrap,这将有效。查看TSref了解详情。

答案 1 :(得分:1)

我能够通过在TS中使用CASE对象来完成此操作。以下是示例代码:

temp.meni0= HMENU
temp.meni0.special = list
temp.meni0.special.value = 5417, 5418, 5419, 5420, 5421
temp.meni0.wrap = <div class="dropdown_5columns"><div class="col_1"><ul>|</ul></div></div>
temp.meni0.1 = TMENU

temp.meni0.1{
  expAll = 1
  NO {
   allWrap = <li>|</li>
   #ATagParams.insertData = 1
   #ATagParams = class="drop"

  }
}


temp.meni6= HMENU
temp.meni6 < temp.meni0
temp.meni6.special.value = 5431, 5432, 5433, 5434, 5435
temp.meni6.wrap = <div class="dropdown_5columns m-144"><div class="col_1"><ul>|</ul></div></div>


temp.meni7= HMENU
temp.meni7 < temp.meni0
temp.meni7.special.value = 5456, 5457, 5458, 5459, 5460
temp.meni7.wrap = <div class="dropdown_5columns m-288"><div class="col_1"><ul>|</ul></div></div>



temp.meni8= HMENU
temp.meni8 < temp.meni0
temp.meni8.special.value = 5466, 5467, 5470, 5471, 5472
temp.meni8.wrap = <div class="dropdown_5columns m-432"><div class="col_1"><ul>|</ul></div></div>

lib.meni= HMENU
lib.meni.special = list
lib.meni.special.value = 5395, 5396, 5397, 5398
lib.meni.wrap = <ul id="menu" style="display:none;">|</ul>
lib.meni.1 = TMENU
lib.meni.1{
  expAll = 1
  NO {

   allWrap = <li>|</li>
   ATagParams.insertData = 1
   ATagParams = class="drop _{field:uid}"

    #after.cObject < temp.meni5
    after.cObject = CASE
    after.cObject {
      key.field = uid
      default = TEXT
      default.value = <span>NIJE OK!</span>

      5395 < temp.meni0
      5396 < temp.meni6
      5397 < temp.meni7
      5398 < temp.meni8
    }

  }
}

有了这个,我可以为lib.menu的每个菜单项(页面)插入非常具体的子菜单