2

我正在尝试通过其 URL 获取对象的内容标题下方的 viewlet。如下所示,但使用对象 URL 而不是“plone”。

id="viewlet-below-content-title" tal:content="structure provider:plone.belowcontenttitle"

我可以使用restrictedTraverse 吗?

4

1 回答 1

1

最好的办法是为belowcontenttitleviewlet 创建一个新视图;模板:

<div tal:content="structure provider:plone.belowcontenttitle"/>

注册:

<browser:page
    for="*"
    name="belowcontenttitle"
    permission="zope2.View"
    template="template_shown_above.pt"
    />

然后您可以通过简单的遍历使用该视图:

<div tal:replace="structure context/path/to/other/object/@@belowcontenttitle" />

这会在另一个对象的上下文中查找视图;模板被渲染并返回,替换div.

于 2013-02-04T21:07:42.640 回答