2011-08-09 93 views
0

我有一個HTML模板,我使用automaketemplate製作了一個typo3模板。在該HTML,我的div這樣如果內部UL沒有值,則不顯示外部div div

<div class="bigPostItWrap">1 
       <div class="postit">2 
        <div class="postit_tesa">3</div> 
        <div class="postItWrap">4 
         <ul class="menusmall">5 
          <li>* Team</li>6 
          <li>* something else</li> 
          <li>* Third point</li> 
         </ul> 
        </div> 
       </div> 
    </div> 

的UL的設置應包含第二個功能,僅當選擇特定主導航對象顯示。由於它位於其他地方在屏幕上,我做了一個獨立的菜單這樣

postitMenu = HMENU 
postitMenu { 
    # show the submenue relative to this entry level (?) 
    entryLevel = 1 
    # the first level of the menu is a text menu 
    1 = TMENU 
    # wrap the whole menu with <ul class="menu"> | </ul> 
    1.wrap = <ul class="menusmall"> | </ul> 

    # enable the "no"rmal state 
    1.NO = 1 
    # for the normal state, wrap it in li 
    1.NO.linkWrap = <li>* |</li> 

    #enable active state 
    1.ACT = 1 
    #copy all properties from normal state to active state 
    1.ACT < .NO 
    # disable the link for the active menu-point 
    1.ACT.doNotLinkIt = 1 
    # wrap the active menulink in li with the class = "active" 
    1.ACT.allWrap = <li class="active">* |</li> 
} 

這一切都工作得很好,菜單隻被顯示在正確的主菜單項。但外部的div postit包含一個背景圖片(你可能猜到,它是一個postIt),postit_tesa在郵件的頂部顯示一條膠帶。當然,如果我不顯示次要菜單,我也不希望postIt和膠帶被渲染。

由於我對typoScript相當陌生,我不知道如何實現這一點。我不知道如何谷歌,至少我沒有找到任何解決方案。我認爲,在某種程度上,如果我做了bigPostItWrap圍繞它,我可以做這樣的事情

if there is an li-element, 
render the subpart bigPostItWrap, 
else, don't render it 

但II不能TS-IF,或做一些完全以錯誤的。任何暗示表示讚賞後面得到。這可能是一個親可笑容易,但我無法弄清楚,我試圖從前天起.-

謝謝!

回答

0

對於任何面臨同樣問題的人:我做了一個作弊......實際上有兩種方法。

首先,我只是做了外部包裝div,併爲其分配了所有其他代碼,並且在此代碼中構建了菜單,如果頁面ID是我想要的。這有效,但並不好。

第二,可能更乾淨的方法是通過CSS ..只需將包裝的可見性設置爲隱藏。不是讓TYPO3給你的身體標籤UID body標籤

# generate a bodyTag with the current page UID 
page.bodyTag > 
page.bodyTagCObject = TEXT 
page.bodyTagCObject.field = uid 
page.bodyTagCObject.wrap = <body id="pid-|"> 

在CSS裏,做一個新的選擇(假設第3頁是你想要的菜單出現的那個)

#pid-3 .your-wrappers-name { 
visibility: visible; 
} 

有你走。 Div只會在UID爲3的頁面上顯示。