Plone has multiple ways of excluding a content object from the navigation:
idsNotToList in portal_properties/navtree_propertiesmetaTypesNotToList in portal_properties/navtree_propertiesThis works fine but the item is still displayed in the navigation tree if it's the current item (the one you're currently viewing). This may have a reason (usability?) but it is not what I want in some cases. If you put a link to the terms and conditions in the footer, for example, you don't want this to show up in the navigation tree when you click on it.
To solve this you can override the template for the navigation portlet (it may also work for the portal tabs) and add the conditions for the exclusion there.
Copy the files navigation.pt and navigation_recurse.pt to your package. Then create a file navigation.py with the following content to create your own renderer based the original overriding the templates:
Next, you have to register the class in the configure.zcml to override the original renderer.
(Note: If you want to do this for one theme only, put the code into your theme package and add layer="..browser.interfaces.IThemeSpecific" to the <plone:portletRenderer> element.)
If you restart Zope now, you are using your own class and templates but there's no difference, yet.
First we expose the idsNotToList and metaTypesNotToList properties to the templates by adding the following to navigation.py:
Now we can finally add the conditions to the template so the item is not displayed in the navigation portlet any more. In navigation_recurse.pt change
to
That's it!
References:
| Anhang | Größe |
|---|---|
| plonetutorial.excludefromnav-1.0dev-py2.4.egg | 5.84 KB |
| Bild 10.png | 169.72 KB |
| Bild 11.png | 169.42 KB |
| Bild 13.png | 146.64 KB |