[Zope] Nested dtml???

Curtis Maloney curtis@umd.com.au
Wed, 30 Aug 2000 10:24:36 +1100


On Tue, 29 Aug 2000, Tim Hicks wrote:
> I am trying to work my way up through folders, checking whether each
> folder has a property named 'site_root_folder'.  Logically (in *my*
> head anyway), what I have written below is what I want to do, but I'm
> not sure that I'm really writing this the write way.  I vaguely
> remember reading that I can't nest dtml-if tags within dtml-in tags.
>
> I'd really appreciate any help on this
>
> tim
>
> <dtml-let level=0>
> <dtml-in level>
> <dtml-if "PARENTS[level].hasProperty('site_root_folder')">
> <dtml-var "PARENTS[level].absolute_url()">
> <dtml-else level="level+1">
> </dtml-in>
> </dtml-let>
>
>
Hmm.. it may be slower, but I would normally use a recursive function in this 
case.

DTML Method  findRoot

<dtml-if "PARENTS[rootLevel].hasProperty('site_root_folder')">
  <dtml-return PARENTS[rootLevel].absolute_url()">
<dtml-else>
  <dtml-return "findRoot(_.None, _, rootLevel=rootLevel+1)">
</dtml-if>


Use as:

<dtml-var "findRoot(_.None, _, rootLevel=0)">

> Tim:  tim.hicks@iname.com
>

If you don't mind my asking, why do you need to hunt down this folder?  Is 
there no way Acquisition could be used to simplify your life?

Have a better one,
	Curtis