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
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
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 )
At 03:48 19/10/99 , Philipp Auersperg wrote:
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?
I can't believe that any of the older Zopistas on this list have not given a reference to the previous discussion on this subject, and its solution. Don't reinvent the wheel! Here is the complete discussion: http://www.zope.org/pipermail/zope/1999-June/thread.html#6127 -- Martijn Pieters, Web Developer | Antraciet http://www.antraciet.nl | Tel: +31-35-7502100 Fax: +31-35-7502111 | mailto:mj@antraciet.nl http://www.antraciet.nl/~mj | PGP: http://wwwkeys.nl.pgp.net:11371/pks/lookup?op=get&search=0xA8A32149 ------------------------------------------
Dear Martijn, Thanks for the hint, there was the solution for my problem, for those who are interested and did not scan the old archives the solution in short: I have to add "id=CategoryID" to the tree tag, see dtml-snippet below, otherwise I have to click two or more times on the branches of the tree to expand. <dtml-let categoryID="0"> <dtml-tree id= categoryID branches_expr="Category(parentid=categoryID)"> <dtml-var name><br> </dtml-tree> </dtml-let> ----- Original Message ----- From: Martijn Pieters <mj@antraciet.nl> To: Philipp Auersperg <zope@philosoft.at>; Steen Suder <CAB@kollegie6400.dk>; <zope@zope.org> Sent: Tuesday, October 19, 1999 10:19 AM Subject: Re: [Zope] dtml-tree based on a recursive SQL table
At 03:48 19/10/99 , Philipp Auersperg wrote:
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?
I can't believe that any of the older Zopistas on this list have not given a reference to the previous discussion on this subject, and its solution. Don't reinvent the wheel! Here is the complete discussion:
http://www.zope.org/pipermail/zope/1999-June/thread.html#6127
-- Martijn Pieters, Web Developer | Antraciet http://www.antraciet.nl | Tel: +31-35-7502100 Fax: +31-35-7502111 | mailto:mj@antraciet.nl http://www.antraciet.nl/~mj | PGP: http://wwwkeys.nl.pgp.net:11371/pks/lookup?op=get&search=0xA8A32149 ------------------------------------------
_______________________________________________ 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 )
participants (3)
-
Martijn Pieters -
Philipp Auersperg -
Steen Suder