2012-08-15 15 views
0

我試圖使用getText基於每個全局選項卡(每個選項卡將加載不同的html頁面)加載不同的html頁面。有誰知道代碼爲每個不同的文本指定一個特定的選項卡?下面的代碼加載相同的文本到所有標籤:加載基於全局選項卡的html(getText)

<div class="col_3" metal:define-macro="highlights" i18n:domain="plone"> 
<h2>Highlights</h2> 
<p> 
<tal:block tal:condition= "exists:here/graduate-study/highlghts-grad" 
tal:replace="structure here/graduate-study/highlghts-grad/getText">Footer content here</tal:block> 
</p> 
</div> 
<div class="col_3" metal:define-macro="highlights" i18n:domain="plone"> 
<h2>Highlights</h2> 
<p> 
<tal:block tal:condition= "exists:here/undergraduate-study/highlghts-grad" 
tal:replace="structure here/undergraduate-study/highlghts-grad/getText">Footer content here</tal:block> 
</p> 
</div> 

等,等所有標籤...

+0

問題是什麼 - 閱讀這篇文章三次仍然沒有給我任何洞察你真正的問題。 – 2012-08-16 04:46:40

回答

1

在Plone全球標籤是導航根。您可以檢測兩種方式當前活動導航根:

  • 人體HTML標籤具有section-[id_of_section] CSS類,其中id_of_section每部分的路徑各不相同。

    從一個Viewlet或portlet可以檢索使用@@plone_layout考慮到這些類:

    tal:define="plone_layout context/@@plone_layout; 
          bodyClass python:plone_layout.bodyClass(template, view)" 
    

    之後,你就必須測試,如果一定state-字符串出現在bodyClass值。

  • 直接從@@plone_portal_state視圖檢索他當前導航根:

    tal:define="plone_portal_state context/@@plone_portal_state; 
          nav_root plone_portal_state/navigation_root; 
          nav_root_id nav_root/getId" 
    

    基礎上,nav_root_id然後你可以改變你的Viewlet或portlet。

不過請注意,每個導航根是有一個門戶網站類型,以及可能的接口聲明,你可以用它來註冊的Viewlets或portlet的。檢測確切的導航通常不是最佳選擇。

+0

另請參閱http://collective-docs.readthedocs.org/en/latest/functionality/actions.html#tabs-sections – 2012-08-16 09:55:09

+0

如果它有幫助,這裏是我想要實現的圖像:[鏈接](http: //static.inky.ws/image/2602/image.jpg) – emb03 2012-08-16 13:45:07

+0

@ emb03:然後使用JavaScript和CSS選擇器; body標籤有一個'section-'類。 – 2012-08-16 13:49:05

0

這個效果通常被稱爲「megamenu」。有一種產品爲Plone執行此操作,http://plone.org/products/collective.collage.megamenu/。我沒有用過它,但我肯定會建議你將它作爲一個起點。

+0

我試過了,但是我通過buildout安裝了錯誤,所以無法添加它。 – emb03 2012-08-17 15:56:03

相關問題