[Zope] dtml-tree with interactive root

Werner Fabian Werner.Fabian@t-online.de
Tue, 23 Jul 2002 21:26:56 +0200

(My apologies if You already got this via Zope-forum. I'll avoid 
double-posting in the future.)

I want to give the user the following functionality:

1. From some folder deep down the directory tree ("start folder") she/he 
may open a tree-view
with the root at this start folder.

2. Interactively, she/he may create tree-views with the root shifted up 
by one or more levels up to the root
of the Zope-tree (or wherever the rights allow).

I tried to code this the following way:

In the root folder there is a dtml-method called "show-tree" which does 
essentially this:

    <dtml-tree expr="REQUEST.PARENTS[uplevel]"
Method','DTML Document'])">

    <a href="<dtml-var absolute_url>">  <dtml-var title_or_id>


This method is called from the "start folder" in essentially the 
following way:

    <dtml-var standard_html_header>

    <dtml-unless uplevel> <dtml-call "REQUEST.set('uplevel' , 

    <dtml-call "REQUEST.set('uplevel', _.int(uplevel))">
    <dtml-call "REQUEST.set('uplevelp', uplevel+1)">

    <a href="<dtml-var URL0>?uplevel=<dtml-var uplevelp>">Up</a>
    <dtml-var show_tree>

    <dtml-var standard_html_footer>

This works OK.
However, if - after having pushed up the tree-root by some levels - I 
want to expand or collapse one of the
branches by using the +/- - icons, the tree is displayed with "start 
folder" as root again, instead of the
folder where I tried to expand/collapse the branch. ("expand/collapse 
all" works!)

How do I avoid this?

Thanks in advance!