[Zope] dtml-tree based on a recursive SQL table

Steen Suder CAB@kollegie6400.dk
Mon, 18 Oct 1999 18:10:31 +0000


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