[Zope] laction-bar with absolute url's

Joachim Werner joe@iuveno-net.de
Wed, 18 Apr 2001 17:26:13 +0200


> I want to implement a location bar on my webpage like zope has implemented
> (not at the webpage but at application).
> It should look like:
> root / folder / subfolder / ...
> and you should be able to navigate with this location-bar, so that
"folder"
> is a link to root/folder and "subfolder" is a link to
root/folder/subfolder.
> And then "folder should not be a link to root/folder/subfolder/folder just
> because of acqusition.

This is one of the many possible solutions. It works for me (comments in ***
***):

*** initialize breadcrumb_start variable (see below) ***
<dtml-call "REQUEST.set('breadcrumb_start','NO')">
*** using PARENTS, you can later refer to the absolute_url! ***
<dtml-in PARENTS reverse>
*** see below for the task of the breadcrumb_start variable ... ***
 <dtml-if "breadcrumb_start=='YES'">
*** this "if/else" is to make sure that the last element is not a link and
has no trailing "/" ***
  <dtml-if sequence-end>
   <dtml-var id>
  <dtml-else>
   <a href="&dtml-absolute_url;"><dtml-var
id></a>&nbsp;<strong>/</strong>&nbsp;
  </dtml-if>
 </dtml-if>
 *** the site_root has to be set as a property of the root folder; if your
breadcrumbs (that's how these things are called because you find your way
back like in the fairy tales where the kids leave breadcrumbs on the way to
mark the path) start from the root folder, you can remove all the
breadcrumb_start stuff. This just makes sure that your breadcrumbs do not go
up the tree too far ... ***
 <dtml-if "id==site_root">
  <dtml-call "REQUEST.set('breadcrumb_start','YES')">
 </dtml-if>
</dtml-in>

If you manually enter URLs like "folder1/folder2/folder3/folder/1", the full
path will be in the breadcrumbs as PARENTS goes up the acquisition path. I
do not exactly know how to do this with just the absolute path displayed.

It tried something like this to get a list of the "absolute parents":

_.string.split(absolute_url,'/')

But absolute_url doesn't (always) return a string. It seems to behave a bit
strange. Any suggestions? There must be a Zope method for this, yes?

Cheers

Joachim