When using the DTML-IN tag you can use DTML-ELSE when no objects to the expression are found. Is there also something with the DTML-TREE tag? ie. How do you know if DTML-TREE has no objects fullfilling to the braches_expr and thus returns no tree? Tom
When using the DTML-IN tag you can use DTML-ELSE when no objects to the expression are found. Is there also something with the DTML-TREE tag?
<dtml-if myobject> <dtml-tree myobject> ... </dtml-tree> <dtml-else> ...put your else stuff here... </dtml-if>
ie. How do you know if DTML-TREE has no objects fullfilling to the braches_expr and thus returns no tree?
the branches_expr is used to find branches. If the object you supply to the tree tag has no objects fulfilling the brancehs_expr then you'll just get a tree with one root node.
Is there a way to change the look of a tree?
check out: http://classic.zope.org:8080/Collector/374/view http://classic.zope.org:8080/Collector/375/view They may be of some help but I'm not sure exactly what they do :S Chris
<dtml-if myobject> <dtml-tree myobject> ... </dtml-tree> <dtml-else> ...put your else stuff here... </dtml-if>
I don't define myobject. My tree searches certain classes. : <dtml-tree branches_expr="objectValues['MyClass']"> </dtml-tree> This code is defined in the index_html of a container class. So in order to use the 'if' statement, I would need a way to say : 'if a class exists of this type then, otherwise do..'. How can I handle this?
ie. How do you know if DTML-TREE has no objects fullfilling to the braches_expr and thus returns no tree?
the branches_expr is used to find branches. If the object you supply to the tree tag has no objects fulfilling the brancehs_expr then you'll just get a tree with one root node.
Is there a way to change the look of a tree?
check out:
http://classic.zope.org:8080/Collector/374/view http://classic.zope.org:8080/Collector/375/view
They may be of some help but I'm not sure exactly what they do :S
Chris
Tom Deprez wrote:
<dtml-if myobject> <dtml-tree myobject> ... </dtml-tree> <dtml-else> ...put your else stuff here... </dtml-if>
I don't define myobject. My tree searches certain classes. :
<dtml-tree branches_expr="objectValues['MyClass']"> </dtml-tree>
This code is defined in the index_html of a container class.
So in order to use the 'if' statement, I would need a way to say : 'if a class exists of this type then, otherwise do..'. How can I handle this?
Tom, I think you need something like (untested) <dtml-if "_.len(objectValues(['MyClass']))>0"> <dtml-tree objectValues(['MyClass'])> </dtml-tree> </dtml-else> blablablablabla </dtml-if> Rik
I don't define myobject. My tree searches certain classes. :
<dtml-tree branches_expr="objectValues['MyClass']"> </dtml-tree>
This code is defined in the index_html of a container class.
Right, this code has no 'name' specified, so dtml-tree uses the current object. This will be index_html if index_html is a dtml document, or its container if it's a method.
So in order to use the 'if' statement, I would need a way to say : 'if a class exists of this type then, otherwise do..'. How can I handle this?
Actually, <dtml-if "this()"> will probably do it, but I haven't tested it. If your branches expression doesn't return anything, then you should get a tree root with no branches. Now, if you don't want to display a tree for an object unless it is going to have branches, then you want to wrap your dtml-tree in something like: <if "objectValues['MyClass']"> cheers, Chris
Thanks for the all replies! <dtml-if "objectValues(['myClass'])"> <dtml-else> </dtml-if> does the job nicely. Regards, Tom.
participants (3)
-
Chris Withers -
Rik Hoekstra -
Tom Deprez