betabug... Sascha Welter

home english | home deutsch | Site Map | Sascha | Kontakt | Pro | Weblog | Wiki

26 June 2005

Plone: Getting NavTreePortlet to Display Always 2 Sublevels

Sitemap-Mode and getSiteMapDepth might be the answer?
 

Yes, another of those boring technical posts. Trying in Plone to display a NavTreePortlet with always the first and second level of the navigation tree shown. Plus the current page highlighted. Found a hackish solution, but it may not be 100% what other people need. Basically we are switching to "sitemap" mode, set the sitemap depth to 2, and patch NavTreePortlet to highlight the current page in sitemap mode too. Here it comes...


First step is to switch to "sitemap" mode. So customize "portlet_navtree_template" and change the first div with the tal:define of "data" as such:

<div class="portletContent odd" 
tal:define="data here/getSitemapData">
Now go to settings of the NavTreePortlet and change "Depth of sitemap" to "2" (or whatever you like). I believe this will not show sublevels below that, but I may be wrong, haven't actually tested.

This will change the display of the navigation tree a lot, but the downside is that the current item is not highlighted any more. (The current item gets another css class assigned, so by changing that in ploneCustom.css we can alter the appearance of the current item.) We need a fix in the actual code of the NavTreePortlet:

*** NavTreePortlet.py_orig      2005-06-26 08:52:49.000000000 +0200
--- NavTreePortlet.py   2005-06-26 08:48:23.000000000 +0200
***************
*** 54,59 ****
--- 54,61 ----
          if context == self or sitemap:
              currentPath = getToolByName(self, 'portal_url').getPortalPath()
              query['path'] = {'query':currentPath, 'depth':self.getSitemapDepth()}
+             # trying to fix detection of current item in sitemap mode
+             currentPath = '/'.join(context.getPhysicalPath())
          else:
              currentPath = '/'.join(context.getPhysicalPath())
              query['path'] = {'query':currentPath, 'navtree':1}
Apply this patch to NavTreePortlet.py in the INSTANCE_HOME/Products/NavTreePortlet directory with something like
patch -p0 < navtree_sitemap_highlight.patch
As usual this change is at your own risk and you better know what you are doing :-)

Posted by betabug at 09:24 | Comments (0) | Trackbacks (0)
ch athens
Life in Athens (Greece) for a foreigner from the other side of the mountains. And with an interest in digital life and the feeling of change in a big city. Multilingual English - German - Greek.
Main blog page
Recent Entries
Best of
Some of the most sought after posts, judging from access logs and search engine queries.

Apple & Macintosh:
Security & Privacy:
Misc technical:
Athens for tourists and visitors:
Life in general:
<< zope haikus | Main | Afternoon in Athens >>
Comments
There are no comments.
Trackbacks
You can trackback to: http://betabug.ch/blogs/ch-athens/133/tbping
There are no trackbacks.
Leave a comment