如何使导航portlet显示子项甚至是未选中的文件夹?我的意思是初始树状态完全扩展(至少一个级别,即:直接儿童)。
我正在查看INavtreeStrategy,SitemapNavtreeStrategy和INavigationQueryBuilder,但到目前为止还没有见解。
答案 0 :(得分:4)
我看到了Products / CMFPlone / browser / sitemap.py
我只需要使用其查询构建器。这是代码:
from Acquisition import aq_inner
from zope.component import getMultiAdapter
from plone.memoize.instance import memoize
from plone.app.layout.navigation.interfaces import INavtreeStrategy
from plone.app.layout.navigation.navtree import buildFolderTree
from plone.app.portlets.portlets import navigation
from Products.CMFPlone.browser.navtree import SitemapQueryBuilder
class Renderer(navigation.Renderer):
@memoize
def getNavTree(self, _marker=[]):
context = aq_inner(self.context)
**queryBuilder = SitemapQueryBuilder(context)**
strategy = getMultiAdapter((context, self.data), INavtreeStrategy)
return buildFolderTree(context, obj=context, query=queryBuilder(), strategy=strategy)
然后我注册了一个portlet渲染器:
<configure
xmlns="http://namespaces.zope.org/zope"
xmlns:browser="http://namespaces.zope.org/browser"
xmlns:plone="http://namespaces.plone.org/plone">
<include package="plone.app.portlets" />
<plone:portletRenderer
portlet="plone.app.portlets.portlets.navigation.INavigationPortlet"
layer="..browser.interfaces.IThemeSpecific"
class=".navigation.Renderer"
/>
</configure>
答案 1 :(得分:0)