[Zope] how to iterate through two sequence items

Peter Walerowski peter.walerowski@densxl.de
Mon, 11 Feb 2002 18:18:50 +0100


>this is testet:
>
>
><dtml-let ov="objectValues('my Object')"
>               lv="_.len(ov)"
>>
><dtml-in "_.range(0, lv, 2)">
><dtml-let i1=sequence-item>
><tr>
><td><dtml-var "ov[i1].getProperty('firstProp')"></td>
><td><dtml-var "ov[i1+1].getProperty('firstProp')"></td>
></tr>
><tr>
><td><dtml-var "ov[i1].getProperty('secondProp')"></td>
><td><dtml-var "ov[i2].getProperty('secondProp')"></td>
></tr>
></dtml-let i1>
></dtml-in>
></dtml-let ov>
<dtml-let ov="objectValues('my Object')"
               lv="_.len(ov)"
>


and if you want to eliminate an error when your sequence is odd:


<dtml-in "_.range(0, lv, 2)">
<dtml-let i1=sequence-item>
<tr>
<td><dtml-var "ov[i1].getProperty('firstProp')"></td>
<td>
  <dtml-if "(i1+1)<lv">
    <dtml-var "ov[i1+1].getProperty('firstProp')">
  <dtml-else>
    &nbsp;
  </dtml-if>
</td>
</tr>
<tr>
<td><dtml-var "ov[i1].getProperty('secondProp')"></td>
<td>
  <dtml-if "(i1+1)<lv">
    <dtml-var "ov[i1+1].getProperty('secondProp')">
  <dtml-else>
    &nbsp;
  </dtml-if>
</td>
</tr>
</dtml-let i1>
</dtml-in>
</dtml-let ov>