navtree_properties not picked up by navigation portlet in policy product
optilude at gmx.net
Sat Oct 27 14:17:11 UTC 2007
Wichert Akkerman wrote:
> Previously Sean F wrote:
>> Hola list..
>> I'm working my way through Martin's new book, building a site policy
>> product for a client project, and I've hit a snag.
>> One of the requirements are some changes to the default nav portlet
>> configuration, which I have set in propertiestool.xml:
>> <?xml version="1.0"?>
>> <object name="portal_properties" meta_type="Plone Properties
>> <object name="navtree_properties" meta_type="Plone Property
>> <property name="currentFolderOnlyInNavtree" type="boolean">True</
>> <property name="includeTop" type="boolean">True</property>
>> <property name="topLevel" type="int">0</property>
>> <property name="bottomLevel" type="int">0</property>
> the navigation portlet itself stores those settings now, they are no
> longer stored in the portal properties.
Almost - the navtree portlet will use navtree_properties as a fallback
in the cases when it makes sense, though here, since it's a boolean, the
setting is on the portlet itself.
To do this, you'll need a call in setuphandlers.py that does something like:
from plone.portlets.constants import CONTEXT_CATEGORY
from plone.app.portlets.utils import assignment_from_key
# 'context' here is the GS context passed to the setup handler
site = context.getSite()
navtree = assignment_from_key(site, 'plone.leftcolumn',
CONTEXT_CATEGORY, '/', 'navigation')
navtree.currentFolderOnly = True
So - we use the assignment_from_key() helper method to get the actual
portlet assignment, looking from the root of the site, in the
plone.leftcolumn portlet manager, in the "contextual portlets" category,
under the key "/" (the root of the site), and finding the portlet
assignment with the name 'navigation' (which is the default name of the
assignment for the navtree portlet when a new Plone site is set up).
Author of `Professional Plone Development`, a book for developers who
want to work with Plone. See http://martinaspeli.net/plone-book
More information about the Product-Developers