[Zope] tree tag global navigation

Michael Bernstein mbernstein@profitscape.net
Tue, 23 Feb 1999 10:48:01 -0800


Fellow Zopesters,

Here is a short tutorial on using the tree tag for global navigation in
your site.

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: 


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.

I hope this helps others who may have been struggling with this.

Michael Bernstein