[Zope] Problem creating navigation bar

David C. Morrill dmorrill@austin.rr.com
Wed, 13 Oct 1999 15:55:38 -0500


This has probably already been covered many times before, but my scan of the
mailing list didn't turn up anything, so here it comes again...

I want to build a navigation bar for a folder with each sub-folder having a
certain property (e.g. 'isMenu') defined creating a link in the nav bar
(i.e. sub-folders without the 'isMenu' property being defined should not be
in the nav bar). Seems pretty simple so far.

When a sub-folder is selected, I want it to display the same nav bar as the
parent folder to allow navigation within this section of the site.

The problem is that the nav bar for the sub-folders do not show any items at
all (because their PARENTS[0] is not the same as for the parent folder).
I've tried a lot of different things (too numerous to list here), but in all
cases the acquisition logic defeated my attempts to solve it.

I finally got it to work by using the following:

<dtml-if "PARENTS[0].id == 'rootFolder'">
  <dtml-call "REQUEST.set('root',PARENTS[0])">
<dtml-else>
  <dtml-call "REQUEST.set('root',PARENTS[1])">
</dtml-if>
<dtml-in "root.objectValues(['Folder'])">
  <dtml-with sequence-item only>
    <dtml-if "_.has_key('isMenu')">
      ...<dtml-var id>...
    </dtml-if>
  </dtml-with>
</dtml-in>

The thing I don't like is having to test explicitly for the name of the root
folder in the top line, since it prevents me from using the same DTML in
some other part of the site. Does someone have a suggestion for a better way
of doing this whole thing?

Dave Morrill