[Zope] Problem refering to a subfolder object

michel@digicool.com michel@digicool.com
11 Jul 1999 13:22:50 -0400


Kam Cheung <zope@littlecircle.com> writes:

> A very newbie question:
> 
> How can I refer to a subfolder object? Basically, what I am trying to do is.
> given a string, I want to detect whether an image with the same name as the
> string exists or not in a subfolder, if it does, it display the object, if
> not, it will show a default image. Here is what I have tried, but doesn't
> work:
> 

<snip>

> That doesn't work. I did find a way to do it by doing:
> 
> <!--#with images-->
>  <!--#with global-->
>   <!--#if name=section-->
>    <IMG SRC="images/global/<!--#var section-->">
>   <!--#else-->
>    <IMG SRC="images/global/default">
>   <!--#/if-->
>  <!--#/with-->
> <!--#/with-->
> 
> But I think there must be an easier way to do that.
> 
> 

That's hard?  ;) Actually, your second way is probably the prefered
'Zope' way to do it.  One quick impovement I can see is that you don't
need the 'name=' in the if tag:

<!--#if section-->

Will do what you want. The #with tag comes in very handy when you are
nesting objects within object.  In some applications, In some
applications, I've had four or five levels of #with nesting.  Any more
than that, however, would mean that the problem probably needs to be
decomposed some more.

-Michel

> 
> 
> Kam On Cheung
> 
> _______________________________________________
> Zope maillist  -  Zope@zope.org
> http://www.zope.org/mailman/listinfo/zope
> 
> (For developer-specific issues, use the companion list,
> zope-dev@zope.org - http://www.zope.org/mailman/listinfo/zope-dev )