[Zope] dtml-in syntax

Tim Cook twcook@iswt.com
Sat, 29 Jul 2000 22:00:27 +0000


Kyle Burnett wrote:
> 
> so i have this loop and i want to count a variable:
> 
> <dtml-in wherever>
> 
>   <dtml-if sequence-start>
>    <dtml-var count-id>
>   </dtml-if>
> 
> </dtml-in>
> 
> but what i really want to count is specific values for id. so let's say
> id=='value1', i want to try and do the following:
> 
> <dtml-in wherever>
> 
>   <dtml-if sequence-start>
>    <dtml-var "count-id=='value1'">
>   </dtml-if>
> 
> </dtml-in>
> 
> but no luck. and i have tried several other make-shift syntaxes to no avail.
> 
> i do have some other logic that i could use over the course of the loop to
> determine the count of distinct values but i was try to do it in far less
> code.

This may be what you already thought of. It does require a lot of
code if you have several things to count.  There may also be
cleaner ways to do it???

<dtml-call "REQUEST.set('this_count', 0)">
<dtml-in wherever>
  <dtml-call "REQUEST.set('current_id', _['sequence-item'])">
  <dtml-if "current_id=='id_to_count'">
    <dtml-call "REQUEST.set('this_count', this_count+1)">
  </dtml-if current_id>
</dtml-in wherever>
I counted <dtml-var this_count> items.

(of course this is untested)<g>.

-- Tim Cook --
FreePM Project Coordinator - http://www.freepm.org
OS Healthcare Alliance Supporter - http://www.oshca.org