Forums / General / Does backward iteration work?

Does backward iteration work?

Author Message

Michael D.

Friday 28 January 2005 1:27:20 am

<h3>Iterating 5 times, backwards</h3>

{section name=Num loop=-5}
{$Num:index}:{$Num:number}:{$Num:key} Number: {$Num:item}<br/>

{/section}

outputs for me (using eZ publish 3.5.0):

Iterating 5 times, backwards
0:1:0 Number: -1
1:2:1 Number: -2
2:3:2 Number: -3
3:4:3 Number: -4
4:5:4 Number: -5

This makes no difference to loop=5 besides $Num:item being negative.

How can I achieve backward iteration?

Jan Borsodi

Friday 28 January 2005 2:13:36 am

You can reverse the iteration by setting the <i>reverse</i> attribute.

{section name=Num loop=-5 reverse}
{$Num:index}:{$Num:number}:{$Num:key} Number: {$Num:item}<br/>
{/section}

--
Amos

Documentation: http://ez.no/ez_publish/documentation
FAQ: http://ez.no/ez_publish/documentation/faq

Michael D.

Friday 28 January 2005 8:36:31 am

Thank you, works.

Might be helpful to add this to the docs (http://www.ez.no/ez_publish/documentation/development/libraries/ez_template/functions/section<b></b>).

I would do it myself but I think I should read "about" and "guidelines" before, but these links are empty.