[Zope] DTML Problem (from the newbie "hair ripper" category)

Dieter Maurer dieter@handshake.de
Mon, 17 Jul 2000 09:06:41 +0200 (CEST)


Darin Lee writes:
 > Here is the proverbial rub. If I want to *test* for the presence of
 > "navigation_name" so I can print "title_or_id" if it's not defined, Zope
 > simply skips the "navigation_name" property. It's like it always evaluates
 > to false!
 > <dtml-in "objectValues(['Category'])">
 >  <dtml-with sequence-item>
 >  <dtml-if "hasProperty('navigation_name')">
 >   <dtml-var navigation_name>
 > <dtml-else>
 >  <dtml-var title_or_id>
 > </dtml-if>
 > </dtml-with>
 > </dtml-in>
 > 
 > Doesn't work!
I do not yet know the method "hasProperty".

As a short term work around, you may try directly:

<dtml-if navigation_name>
  <dtml-var navigation_name>
<dtml-else>
  <dtml-var title_or_id>
</dtml-if>

This may acquire "navigation_name". Thus, you may restrict
namespace lookup with:

<dtml-with sequence-item only>
<-- code above-->
</dtml-with>


Dieter