ViewHelper Documentation
for
Loop view helper which can be used to interate over array. 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 \TYPO3\CMS\Extbase\Persistence\ObjectStorage to iterated over
as string, required
The name of the iteration variable
key string, required
The name of the variable to store the current array key
reverse boolean, required
If enabled, the iterator will start with the last element and proceed reversely
iteration string, required
The name of the variable to store iteration information (index, cycle, isFirst, isLast, isEven, isOdd)