How can I make the navigation portlet show children even for unselected folders? I mean initial tree state is fully expanded (at least for one level, ie: direct children).
I'm looking at INavtreeStrategy, SitemapNavtreeStrategy and INavigationQueryBuilder but no insights so far.
I got it looking at Products/CMFPlone/browser/sitemap.py
I just had to use its query builder instead. Here's the code:
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)
Then I registered a portlet renderer with:
<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>
See the documentation of ExtendedPathIndex
http://plone.org/products/extendedpathindex
A combination of navtree and depth parameter should give you what you need.