[Zope] dtml-tree based on a recursive SQL table
Philipp Auersperg
zope@philosoft.at
Tue, 19 Oct 1999 03:48:08 +0200
Steen,
Thanks for your answer, I did the following:
0. define a SQL table named category:
create table category(categoryID int primary key,parentID int,name
varchar(30))
1. implement a Z SQL method named Category(parent):
select *
from Category where parentid=<dtml-var parentid>
2. add the following DTML for example into index_html:
<dtml-let categoryID="0">
<dtml-tree branches_expr="Category(parentid=categoryID)">
<dtml-var name><br>
</dtml-tree>
</dtml-let>
now the tree expands and collapses fine but I have to click thw branches 2
to several times before they expand/collapse.
so dear zopers what is the trick?
thanks
phil
----- Original Message -----
From: Steen Suder <CAB@kollegie6400.dk>
To: <zope@zope.org>
Sent: Monday, October 18, 1999 8:10 PM
Subject: Re: [Zope] dtml-tree based on a recursive SQL table
> Philipp Auersperg wrote:
> >
> > Hi!
> >
> > given a recursive table named
> > <<Category (CategoryID int primary key,parentID int foreign key
references
> > Category.CategoryID,name varchar(30)) >>
> > I would like to display that table with the tree tag. On the top-level
it
> > should display the categories where parentid=0, for each branch there
should
> > appear the categories with their parentID pointing to the categoryID of
the
> > branch and so on... (I hope you understand). I scanned all the docs but
did
> > not find any solution.
> >
> > I started with:
> >
> > <dtml-tree branches_expr="Category()">
> > <dtml-var name>
> > </dtml-tree>
> >
> > (Category is a Z SQL method returning the whole table)
> >
> > this displays the top level records but of course not the subcategories.
How
> > can I bring the recursion into that ?
> >
> > Thanks in advance
> > Philipp Auersperg
>
> It's like having some sort of tree consisting of linked lists, right?
>
> I've asked the same question a couple of times on the list, but I didn't
> get any responses.
>
> Instead of having Category() returning all of the table, why not give it
> "the current parrent node id" as argument? This approach will require
> one to meddle with nodelists separately as I understand it.
>
> Then it first build level 1 (level 0 is root with a fixed id) from the
> ojects in the results of Category(id=<root id>). Level 2 is for every
> node in level 1 (Category(id=<current id>)) and so on.
> Termination condition is [no records], EOF or whatever it's called.
>
> But then again; I'm not a programmer.
> Just a thought, though....
>
>
> I'd very much appreciate input on this as well as Phillipp.
>
> --
> Best regards / Mvh.,
> Steen Suder
> sysadm kollegie6400.dk
> OpenSource --- Sign of the time
>
> _______________________________________________
> Zope maillist - Zope@zope.org
> http://www.zope.org/mailman/listinfo/zope
>
> (Related lists - please, no cross posts or HTML encoding!
>
> To receive general Zope announcements, see:
> http://www.zope.org/mailman/listinfo/zope-announce
>
> For developer-specific issues, zope-dev@zope.org -
> http://www.zope.org/mailman/listinfo/zope-dev )