我有这样的东西:site/country-1/item-1/item-2/item-3
在项目 3 中,我有一个 portlet。在它的模板中,我试图显示 Item 2
的标题或 Item 1
.我该怎么做?
<div tal:content="python:context.Title()"></div>
给我Item 3
.
<div tal:content="python:context.aq_parent"></div>
给我<plone.app.portlets.portlets.classic.Renderer object at 0x7fa76b97a990>
<div tal:content="python:view"></div>
同样:<plone.app.portlets.portlets.classic.Renderer object at 0x7fa76b97a590>
我需要此信息来实现解决方案,以在任何级别按母国过滤新闻项和事件。
最佳答案
获取链可能与您预期的不同。
要查看采集链,请检查 context.aq_chain
。
尝试 context.aq_inner.aq_parent
可能会有好运。
无论如何,我会使用 plone_context_state
View ,即:context/@@plone_context_state/parent
。
相关链接:
关于 Plone 4 : Get the parent of a page in a portlet template,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42831635/