Package

ViewHelpers

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> apple cherry strawberry banana

  • green fruits

    <ul>
      <li>0: apple</li>
    </ul>
    

  • red fruits

    <ul>
      <li>1: cherry</li>
    </ul>
    <ul>
      <li>3: strawberry</li>
    </ul>
    

  • yellow fruits

    <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

ViewHelper Resources

Schema Resources