[Zope] Peculiar effects with SQL tree
J C Lawrence
claw@kanga.nu
Tue, 08 Feb 2000 20:46:13 -0800
On Tue, 8 Feb 2000 16:48:58 -0000
Stephen Harrison <stephen@nipltd.com> wrote:
> I have a dtml-tree which is getting its tree data from an sql
> method:
...
> However, with only a small amount of data in the tree table this
> is behaving in a very strange way...
I had similar problems with I set up a tree over an SQL method. I
don't recall exactly how I fixed it, but I can show you what I have:
DTML Method:
<dtml-let CatID="0">
<dtml-tree id=CatID branches_expr="CatCats(CatParent=CatID, Approved=1)">
<dtml-if "_.int(CurrCat) - _.int(CatID)">
<dtml-var PrintCat>
<dtml-else>
<b><<<dtml-var PrintCat>>></b>
</dtml-if>
</dtml-tree>
</dtml-let>
SQL:
SELECT *
FROM Categories
<dtml-sqlgroup where>
<dtml-sqltest CatParent type=int>
<dtml-and>
<dtml-if "_.int(Approved) == 1">
<dtml-sqltest Approved type=int>
</dtml-if>
<dtml-if "_.int(Approved) == -1">
Approved=0
</dtml-if>
</dtml-sqlgroup>
ORDER BY CatName
PrintCat is a DTML method that displays the data on the current
node. CatParent is the table field that points to parents of nodes.
CatID is the field that holds the ID of the current node (which may
be pointed to by some CatParents). You can ignore all the logic
around "Approved" (I have nodes that aren't always visible). The
business with CurrCat is an attempt to highligh the currently
selected node in the tree.
--
J C Lawrence Home: claw@kanga.nu
----------(*) Other: coder@kanga.nu
--=| A man is as sane as he is dangerous to his environment |=--