2011-08-03 97 views
1

我必須使用支持與IRelatedItems行爲的基於敏捷內容類型:呈現敏捷內容類型的相關項目

<property name="behaviors"> 
    <element value="plone.app.relationfield.behavior.IRelatedItems" /> 
</property> 

我要呈現在我的模板相關項目的名單,但我不知道如何去做。

任何提示?

回答

4

發現:第一個自定義視圖必須是一個display form,所以它必須從plone.directives.dexterity.DisplayForm得出:

class MyCustomView(dexterity.DisplayForm): 
    grok.context(IMyContentType) 
    grok.require('zope2.View') 

然後你可以使用像這樣的您的頁面模板:

<fieldset id="related-items" tal:condition="context/relatedItems"> 
    <legend i18n:translate="">Related items</legend> 
    <tal:relateditems tal:content="structure view/w/IRelatedItems.relatedItems/render" /> 
</fieldset> 
3

是不是this你在找什麼?

+0

差不多;該文檔沒有更新,也沒有解釋如何在模板中使用該小部件。 – hvelarde

+0

你最好總結一下你的鏈接的內容(按照StackOverflow'styleguide')。像許多其他plone.org鏈接一樣,這個鏈接已經死了。 – onse

2

你可以考慮使用標準靈巧關係行爲:

plone.app.dexterity.related.IRelatedItems

這種行爲,相關的項目會自動出現在內容的標準視圖。

賈科莫

+2

從v1.0.1開始,在plone.app.dexterity中不推薦使用該行爲;你必須使用plone.app.relationfield中的那個。此外,我需要使用我自己的觀點,而不是標準觀點。 – hvelarde

相關問題