[FLOW3-general] nested lists

Thomas Brandl thomas.brandl at native-instruments.de
Fri Oct 15 10:39:36 CEST 2010


Hey,

groupedFor is brilliant! It's a strategy used so many times in outputs 
that it's great to have this addressed by the template system w/o the 
need for quirks in the model.

Thanks to the patch here also groups by model - love it:
http://forge.typo3.org/issues/show/7389

Best,
Thomas


Bastian Waidelich wrote:
> Michael Stein wrote:
>
> Hi Michael,
>
>> I'm new to fluid.
>> I have a database many object of type A, B, C
>> I need a list
>> - type A:
>> -- obj 1
>> -- obj 2
>> -- obj 3
>> - type B:
>> -- obj 4
>> -- obj 5
>> -- obj 6
>> - type C:
>> -- obj 7
>> -- obj 8
>> -- obj 9
>
> Have a look at the groupedFor ViewHelper. You can use it like:
>
> <ul>
> <f:groupedFor each="{objects}" as="objectsOfThisType" groupBy="type"
> groupKey="type">
> <li>
> type {type}:
> <ul>
> <f:for each="{objectsOfThisType}" as="object">
> <li>{object.title}</li>
> </f:for>
> </ul>
> </li>
> </f:groupedFor>
> </ul>
>
> (untested)
>
> You should also consider creating an intermediate model for the grouped
> representation by adding a method findAllGroupedByType() or similar to
> your repository that returns a nested result (either as more-dimensional
> array or preferably as a new domain object)
>
> HTH,
> Bastian
>


More information about the FLOW3-general mailing list