ViewHelper Documentation
groupedFor
Grouped loop view helper. Loops through the specified values.
The groupBy argument also supports property paths.
= Examples =
<f:groupedFor each="{0: {name: 'apple', color: 'green'}, 1: {name: 'cherry', color: 'red'}, 2: {name: 'banana', color: 'yellow'}, 3: {name: 'strawberry', color: 'red'}}" as="fruitsOfThisColor" groupBy="color">
<f:for each="{fruitsOfThisColor}" as="fruit">
{fruit.name}
</f:for> </f:groupedFor>
<f:groupedFor each="{0: {name: 'apple', color: 'green'}, 1: {name: 'cherry', color: 'red'}, 2: {name: 'banana', color: 'yellow'}, 3: {name: 'strawberry', color: 'red'}}" as="fruitsOfThisColor" groupBy="color" groupKey="color">
<li>
{color} fruits:
<ul>
<f:for each="{fruitsOfThisColor}" as="fruit" key="label">
<li>{label}: {fruit.name}</li>
</f:for>
</ul>
</li>
</f:groupedFor>
<ul>
<li>0: apple</li>
</ul>
<ul>
<li>1: cherry</li>
</ul>
<ul>
<li>3: strawberry</li>
</ul>
<ul>
<li>2: banana</li>
</ul>
Arguments
each anySimpleType, required
The array or \TYPO3\CMS\Extbase\Persistence\ObjectStorage to iterated over
as string, required
The name of the iteration variable
groupBy string, required
Group by this property
groupKey string, required
The name of the variable to store the current group