At 10:48 AM 2/23/99 -0800, Michael Bernstein wrote:
Fellow Zopesters,
Here is a short tutorial on using the tree tag for global navigation in your site.
Thank you Michael! This is a wonderful contribution and I would like to put it up on the Zope site as a How-To.
Step 1: Create an external method with the following code:
def getFoldersOnly(self): """Return a list of only the Folders contained in an object, for use by the tree tag""" return self.objectValues(['Folder'])
This is neccesary in order to avoid listing the product and acl_users folder objects. Thanks to Kent Polk for the code. Modify this code if you want to display something other than just folders, For example:
As was mentioned, this can be accomplished in DTML directly, no need for an external method.
Step 2: Create a DTML method named SideBar in your root folder with the following code:
<!--#tree branches=getFoldersOnly--> <A HREF="<!--#var BASE1-->/<!--#var tree-item-url-->"><!--#var id--></A> <!--#/tree-->
Notice that we are generating absolute URL's. Thanks to Kent Polk and Martijn Pieters for this code.
Step 3: Call SideBar with the following code from anywhere in your site using this code:
<!--#var "SideBar(PARENTS[-1],REQUEST)"-->
And voila! it should display a tree of your entire site structure! Thanks to Amos Latteier for this deceptively simple code snippet.