----- Original Message -----
From: "Curtis Maloney" <[EMAIL PROTECTED]>
To: "Tim Hicks" <[EMAIL PROTECTED]>; "zope" <[EMAIL PROTECTED]>
Sent: Wednesday, August 30, 2000 12:24 AM
Subject: Re: [Zope] Nested dtml???

> On Tue, 29 Aug 2000, Tim Hicks wrote:
> > I am trying to work my way up through folders, checking whether
> > folder has a property named 'site_root_folder'.  Logically (in
> > head anyway), what I have written below is what I want to do, but
> > 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
> >
> > 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)">

Thanks for the ideas, but I have managed to do what I wanted to do
using the code below (with help from Dieter Maurer).

<dtml-in PARENTS>
<dtml-let PARENT="_.getitem('sequence-item')">
<dtml-if "PARENT.hasProperty('site_root_folder')"><dtml-var

> >
> 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?

I have made a couple of 'sites' that need to be portable so that they
can be placed on any server, with their 'root' directory having any
name without needing to edit anything. Therefore, in every link/URL
within the site, I do something like the following,

href="<dtml-var path>/link/to/whatever.html"

The path method is what contains the code that I have shown above.  In
this way, all the links work no matter what server they are placed on
(zope of course!).  I don't think I could have just used relative
links as my standard_html_header/footer contains links/images.  With
relative links, when the header/footer was placed into a document that
was not in the site's root folder, they were broken.

Does that make any sense?  Have I gone about it a bit backwards?

Anyway, you did ask :-)


> Have a better one,
> Curtis

Zope maillist  -  [EMAIL PROTECTED]
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-dev )

Reply via email to