[Zope] Equality test: if sequence-item = document id

Nils Kassube lists@kassube.de
Mon, 4 Jun 2001 14:07:56 +0200


Guten Abend.

* Garry Steedman <gs@styrax.com> [2001-06-01 16:52]:
 
> <DIV CLASS=navigation VALIGN="top">
> <dtml-in "PARENTS[0].objectValues('DTML Document')"
> sort=menu_sort_order>
> <dtml-if "hasProperty('menu_sort_order')">
> <dtml-if "_['sequence-item']==this_id">
> &nbsp;&nbsp;<a href="&dtml-absolute_url;">[<dtml-var title>]</a>
> <dtml-else>
> </dtml-if>
> &nbsp;&nbsp;<a href="&dtml-absolute_url;"><dtml-var title></a>
> <dtml-else>
> </dtml-if>

Are you sure this is what's in your method? It looks like you're trying
to add [ ] brackets to the current document in the navigation list. The
two <dtml-else></dtml-if> look wrong. It's also a good idea to avoid
links to the current document in the same document. Well, and
'sequence-item' is the object in this case, not the id, because you use
objectValues(), not objectIds(), so you have to use getId() to, er, get
the id of the object. 

This will work: 

<dtml-in expr="PARENTS[0].objectValues('DTML Document')"
sort=menu_sort_order>
<dtml-if expr="hasProperty('menu_sort_order')">
<dtml-if expr="getId() == this_id">
&nbsp; &nbsp; [<dtml-var title>] 
<dtml-else>
&nbsp; &nbsp; <a href="&dtml-absolute_url;"><dtml-var title></a>
</dtml-if>
</dtml-if> 
</dtml-in>

Cheers,
Nils