Left navigation bar; how to implement one.
Greetings. I searched in many places, but I could not find an example on how to create a left navigation bar with Zope. I might have some ideas, but I would like to hear from you oldies (as opposed to newbies) the most efficient way to create one. Off course, the left navigation bar should show up on each web page of the site, it would expand as the user goes in deeper on the site and you would only need to write it once and use it on all of the web pages. I am a newbie to Zope, but not in html or python. Sincerely, Hans Deragon
in standard_html_header: <html><head>..bla.. <body> <table><tr> <td><dtml-var left_navigation></td> <td> in standard_html_footer: </td></tr> </table> </body> </html> in left_navigation:: <a href="links.html">Links</a> Good luck. Look into ZPT and METAL to do it more professionally. At 16:49 2002-12-14 -0500, Hans Deragon wrote:
Greetings.
I searched in many places, but I could not find an example on how to create a left navigation bar with Zope. I might have some ideas, but I would like to hear from you oldies (as opposed to newbies) the most efficient way to create one. Off course, the left navigation bar should show up on each web page of the site, it would expand as the user goes in deeper on the site and you would only need to write it once and use it on all of the web pages.
I am a newbie to Zope, but not in html or python.
Sincerely, Hans Deragon
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
Hi Hans, --On Samstag, 14. Dezember 2002 16:49 -0500 Hans Deragon <hans@deragon.biz> wrote:
Greetings.
I searched in many places, but I could not find an example on how to create a left navigation bar with Zope. I might have some ideas, but I would like to hear from you oldies (as opposed to newbies) the most efficient way to create one. Off course, the left navigation bar should show up on each web page of the site, it would expand as the user goes in deeper on the site and you would only need to write it once and use it on all of the web pages.
I am a newbie to Zope, but not in html or python.
Simple solution: In root or where you want your navigation start, create a pythonscript, lets call it "navigation" like this: ---- *snip* --- # first get all the parents from REQUEST (a list with all the objects in URL) parents=context.REQUEST.PARENTS # then a simple recursive helper function def buildnavigation(baseobject): # decide if we have to look deeper (when we are in the path) if baseobject in parents: return [{'folder':obj, 'subfolders':buildnavigation(obj) } for obj in baseobject.objectValues('Folder')] else: return [] # return the list in list in list object return buildnavigation(container) ---- *snip* ---- In ZPT, it is a bit ugly, but this way you dont violate standards, the idea is to create all levels of navigation (you sure will have a maximum depth you want to display) <div metal:define-macro="navigation"> <ul> <li tal:repeat="nav here/navigation"> <a href="." tal:attributes="href nav/folder/absolute_url" tal:content="nav/folder/title_or_id">..</a> <ul tal:condition="nav/subfolders"> <li tal:repeat="nav nav/subfolders"> <a href="." tal:attributes="href nav/folder/absolute_url" tal:content="nav/folder/title_or_id">..</a> <ul tal:condition="nav/subfolders"> <li tal:repeat="nav nav/subfolders"> <a href="." tal:attributes="href nav/folder/absolute_url" tal:content="nav/folder/title_or_id">..</a> <ul tal:condition="nav/subfolders"> <li tal:repeat="nav nav/subfolders"> <a href="." tal:attributes="href nav/folder/absolute_url" tal:content="nav/folder/title_or_id">..</a> </li> </ul> </li> </ul> </li> </ul> </li> </ul> </div> You can use this macro in all your pages or define a macro for a page which includes the construct and defines a slot for your variable content. HTH Tino Wildenhain
From: "Hans Deragon" <hans@deragon.biz>
I searched in many places, but I could not find an example on how to create a left navigation bar with Zope. I might have some ideas, but I would like to hear from you oldies (as opposed to newbies) the most efficient way to create one. Off course, the left navigation bar should show up on each web page of the site, it would expand as the user goes in deeper on the site and you would only need to write it once and use it on all of the web pages.
I am a newbie to Zope, but not in html or python.
There are many options, depending on what functionality you want. Should the menu be completely static, or should it change depending on where you are? I think the best way to do this is to make each document a folder, that contains both subdocuments (other folders) and the contents of the document. The contents is most easily put into a DTMLMethod that you call "content" or something obvious like that. You can the create a template (either a DTMLMethod or a PageTemplate) in the root that contains the design, and inserts the "content" DTML-method in each page. This will mean that you only have the design in one place (the root) and use it for all document. You then create the menu as a part of this template, and you can have a menu that lists all the sub documents of the document you are currently viewing. Use OrderedFolder for the documents so you control the order or the subfolders. That's it really. It's your own content management system, and it takes a couple of hours to make. :-)
participants (4)
-
Hans Deragon -
Lennart Regebro -
Peter Bengtsson -
Tino Wildenhain