XF 2.1 Template variable $i always starts at 1

AndyB

Well-known member
I would like to get $i to start at 0. The following code does not work, $i it always starts at 1.

Code:
<xf:set var="$i" value="0" />
<xf:foreach loop="$results" value="$result" i="$i">
    {$i}
</xf:foreach>

Thank you.
 
Got it:

Code:
<xf:foreach loop="$results" value="$result" i="$i">
    {{ $i - 1 }}
</xf:foreach>
 
Back
Top Bottom