渲染敏捷内容类型的相关项目

时间:2011-08-03 01:50:35

标签: templates plone dexterity

我有一个基于敏捷的内容类型,启用了IRelatedItems行为:

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

我想在我的模板上呈现相关项目的列表,但我不知道该怎么做。

任何提示?

3 个答案:

答案 0 :(得分: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>

答案 1 :(得分:3)

不是this你在寻找什么?

答案 2 :(得分:2)

你可以考虑使用标准的灵巧关系行为:

plone.app.dexterity.related.IRelatedItems

通过此行为,相关项目会自动显示在内容的标准视图中。

贾科莫

相关问题