2017-07-03 67 views
0

這是我的Typo腳本菜單:TYPO3 Typo腳本菜單:隱藏元素條件

page.10.variables { 
menue = HMENU 
menue { 
#special = directory 
#special.value = 17 
wrap = <div id="mobile-header"><div class="bar"></div></div><div class="menu-collapsed"><div id="navigation"><nav class="nav"><ul>|</ul></nav></div></div> 
1 = TMENU 
1.expAll=1 
1 { 
     NO { 
     wrapItemAndSub = <li>|</li> 
     stdWrap.cObject = TEXT 
     stdWrap.cObject.field = subtitle // title 
     ATagBeforeWrap = 1 
     # linkWrap = |<span class="underline"></span> 
     ATagParams=class="navi" 
      } 
     RO = 1 
     RO {   
     wrapItemAndSub = <li>|</li> 
     stdWrap.cObject = TEXT 
     stdWrap.cObject.field = subtitle // title 
     ATagBeforeWrap = 1 
     # linkWrap = |<span class="underline"></span> 
     ATagParams=class="navi" 
     } 
     ACT = 1 
     ACT { 
     wrapItemAndSub = <li> |</li> 
     stdWrap.cObject = TEXT 
     stdWrap.cObject.field = subtitle // title 
     ATagBeforeWrap = 1 
     # linkWrap = |<span class="underline"></span> 
     ATagParams=class="navi_active" 
     } 

     IFSUB = 1 
     IFSUB { 
     wrapItemAndSub = <li> |</li> 
     stdWrap.cObject = TEXT 
     stdWrap.cObject.field = subtitle // title 
     ATagBeforeWrap = 1 
     linkWrap = |<i class="fa fa-angle-down" aria-hidden="true"></i> 
     ATagParams=class="navi sub" 
      } 

    ACTIFSUB < .IFSUB 

     SPC = 1 
    SPC { 
    doNotLinkIt = 1 
    doNotShowLink = 1 
    allWrap = <div class="space"></div> 
    }  
    } 

    2 < .1 
    2.wrap = <ul class="nav_list1 subnavi resp">|</ul> 
    2.NO.wrapItemAndSub = <li> |</li> 
    2.ACT.wrapItemAndSub = <li> |</li> 
    3 < .2 
    3.wrap = <ul id="subsubnavi">|</ul> 
    } 


menue2 = HMENU 
menue2 { 
special = directory 
special.value = 62 
1 = TMENU 
1.expAll=1 
1 { 
wrap = <div class="box-menue2"><nav class="nav"><ul class="profile_tab">|</ul></nav></div> 
     NO { 
     wrapItemAndSub = <li>|</li> 
     stdWrap.cObject = TEXT 
     stdWrap.cObject.field = subtitle // title 
     ATagBeforeWrap = 1 
     ATagParams=class="navi2" 
    stdWrap.dataWrap =<i class="fa fa-{field:tx_iconfont_icon}" aria-hidden="true"></i> 
    stdWrap.dataWrap.insertData=1 
      } 
     RO = 1 
     RO {   
     wrapItemAndSub = <li>|</li> 
     stdWrap.cObject = TEXT 
     stdWrap.cObject.field = subtitle // title 
     ATagBeforeWrap = 1 
     stdWrap.dataWrap =<i class="fa fa-{field:tx_iconfont_icon}" aria-hidden="true"></i> 
    stdWrap.dataWrap.insertData=1 
     ATagParams=class="navi2" 
     } 
     ACT = 1 
     ACT { 
     wrapItemAndSub = <li> |</li> 
     stdWrap.cObject = TEXT 
     stdWrap.cObject.field = subtitle // title 
     ATagBeforeWrap = 1 
    stdWrap.dataWrap =<i class="fa fa-{field:tx_iconfont_icon}" aria-hidden="true"></i> 
    stdWrap.dataWrap.insertData=1 
     ATagParams=class="navi2_active" 
     } 

     IFSUB = 1 
     IFSUB { 
     wrapItemAndSub = <li> |</li> 
     stdWrap.cObject = TEXT 
     stdWrap.cObject.field = subtitle // title 
     ATagBeforeWrap = 1 
     linkWrap = |<i class="fa fa-angle-down" aria-hidden="true"></i> 
     ATagParams=class="navi2 sub" 
      } 

    ACTIFSUB < .IFSUB 

     SPC = 1 
    SPC { 
    doNotLinkIt = 1 
    doNotShowLink = 1 
    allWrap = <div class="space"></div> 
    }  
    } 

    2 < .1 
    2.wrap = <ul class="nav_list">|</ul> 
    2.NO.wrapItemAndSub = <li> |</li> 
    2.ACT.wrapItemAndSub = <li> |</li> 
    3 < .2 
    3.wrap = <ul id="subsubnavi">|</ul> 
    } 


menue3 = HMENU 
menue3 { 
special = directory 
special.value = 57 
1 = TMENU 
1.expAll=1 
1 { 
wrap = <div class="box-menue3"><nav class="nav3"><ul class="profile_tab">|</ul></nav></div> 
     NO { 
     wrapItemAndSub = <li>|</li> 
     stdWrap.cObject = TEXT 
     stdWrap.cObject.field = subtitle // title 
     ATagBeforeWrap = 1 
     ATagParams=class="navi2" 
    stdWrap.dataWrap =<i class="fa fa-{field:tx_iconfont_icon}" aria-hidden="true"></i> 
    stdWrap.dataWrap.insertData=1 
      } 
     RO = 1 
     RO {   
     wrapItemAndSub = <li>|</li> 
     stdWrap.cObject = TEXT 
     stdWrap.cObject.field = subtitle // title 
     ATagBeforeWrap = 1 
     stdWrap.dataWrap =<i class="fa fa-{field:tx_iconfont_icon}" aria-hidden="true"></i> 
    stdWrap.dataWrap.insertData=1 
     ATagParams=class="navi2" 
     } 
     ACT = 1 
     ACT { 
     wrapItemAndSub = <li> |</li> 
     stdWrap.cObject = TEXT 
     stdWrap.cObject.field = subtitle // title 
     ATagBeforeWrap = 1 
    stdWrap.dataWrap =<i class="fa fa-{field:tx_iconfont_icon}" aria-hidden="true"></i> 
    stdWrap.dataWrap.insertData=1 
     ATagParams=class="navi2_active" 
     } 

     IFSUB = 1 
     IFSUB { 
     wrapItemAndSub = <li> |</li> 
     stdWrap.cObject = TEXT 
     stdWrap.cObject.field = subtitle // title 
     ATagBeforeWrap = 1 
     linkWrap = | 
     ATagParams=class="navi sub" 
      } 

    ACTIFSUB < .IFSUB 

     SPC = 1 
    SPC { 
    doNotLinkIt = 1 
    doNotShowLink = 1 
    allWrap = <div class="space"></div> 
    }  
    } 

    2 < .1 
    2.wrap = <ul class="nav_list">|</ul> 
    2.NO.wrapItemAndSub = <li> |</li> 
    2.ACT.wrapItemAndSub = <li> |</li> 
    3 < .2 
    3.wrap = <ul id="subsubnavi">|</ul> 
    } 

    FOO2 = HMENU 
    FOO2{ 
    special = directory 
    special.value = 18 
    1 = TMENU 
    1 { 
     NO { 
     wrapItemAndSub = | |*| &nbsp;&nbsp; | |*| &nbsp;&nbsp; | 
     } 
    } 
    } 
} 

我需要顯示在狀態菜單中的一些子元素。如果db == 0中的某個字段顯示一個菜單元素,則顯示第二個。可能嗎 ?我希望你明白我想要的。有人能幫助我嗎?

回答

0

'條件'在輸入錯誤方面並不是唯一的。

有'條件'打開和關閉打字稿的部分。

[global] 

這些條件通常取決於頁面調用的環境。

你想要一個依賴於數據庫值的條件,所以你需要使用stdWrap函數來評估數據值。
除了具有多個選項的大功能ifoverride,ifEmptyifBlank

要麼你寫在你的COA替代品和有自己的if包裹每個部分或者你寫的,默認的配置您的TypoScript做這是對的,並切換與自己if包裝的override

對於一個乾淨的錯字腳本,您可以使用temp對象,您可以複製並保持您的使用清潔。
實施例:

temp.alternative1 = COA 
temp.alternative1 { 
    : 
} 
temp.alternative2 = COA 
temp.alternative2 { 
    : 
} 

10 = HMENU 
10 { 
    1 = TMENU 
    1 { 
    : 
    before < temp.alternative1 
    before.override < temp.alternative2 
    before.override.if.isfalse.field = my_field 
    } 
}