ViewHelper Documentation
for
Loop view helper which can be used to iterate over arrays. Implements what a basic foreach()-PHP-method does.
= Examples =
<f:for each="{0:1, 1:2, 2:3, 3:4}" as="foo">{foo}</f:for>
<f:for each="{fruit1: 'apple', fruit2: 'pear', fruit3: 'banana', fruit4: 'cherry'}" as="fruit" key="label">
<li>{label}: {fruit}</li>
</f:for>
<f:for each="{0:1, 1:2, 2:3, 3:4}" as="foo" iteration="fooIterator">
<li>Index: {fooIterator.index} Cycle: {fooIterator.cycle} Total: {fooIterator.total}{f:if(condition: fooIterator.isEven, then: ' Even')}{f:if(condition: fooIterator.isOdd, then: ' Odd')}{f:if(condition: fooIterator.isFirst, then: ' First')}{f:if(condition: fooIterator.isLast, then: ' Last')}</li>
</f:for>
Arguments
each anySimpleType, required
The array or \SplObjectStorage to iterated over
as string, required
The name of the iteration variable
key string, required
Variable to assign array key to
reverse boolean, required
If TRUE, iterates in reverse
iteration string, required
The name of the variable to store iteration information (index, cycle, isFirst, isLast, isEven, isOdd)