[ZDP] DTML-Tree-Tag, need some expert help

Martijn Pieters mj@zope.com
Fri, 25 Oct 2002 11:10:56 -0400

On Fri, Oct 25, 2002 at 11:29:42AM +0200, David Mauser wrote:
> i try to show up an tree and the most things realy work well with the
> DTML-Tree tag. 
> But i wish to expand one Branch at startup of the tree, this is the
> location from where the tree gets started.
> For example:
>    + Section1
>    + Section2
>    - Section3
>      + Folder1
>      - Folder2
>        branch_document1
>        branch_document2
>      + Folder3
> The user clicked on show tree while he was in "branch_document1" and so
> the tree should expand until "branch_document1".
> Is there any easy way to do it?
> I read about the "tree-s" cookie to control the tree-state, but i have no
> clue how to use the encode and decode function to create my own cookie.
> Is there an way to access the tree functions from python? (for calling a
> python script in the tree tag which calls some functions)

The DTML Tree tag does not offer this functionality, unless you figure out
how the tree state cookie is built out. If you do, document it so everyone
can do it too ;)

The ZTUtils package includes a SimpleTree class intended to be a far more
flexible replacement for the DTM LTree, but it is underdocumented. It does,
however, include the ability to set a callback that can influence the state
(open, closed, leaf) for each node that is visible in the tree. Rendering of
the tree is delegated to the template itself. The ZPT package contains a set
of examples that you can import, including a simple example of the
SimpleTree object. The object is not specifically tied to ZPT though, you
should be able to use it in DTML templates as well.

Martijn Pieters
| Software Engineer  mailto:mj@zope.com
| Zope Corporation   http://www.zope.com/
| Creators of Zope   http://www.zope.org/