[TYPO3-mvc] Fluid List Item Issue

Sebastiaan van Parijs svparijs at bkwi.nl
Wed Dec 29 14:08:48 CET 2010


On 12/29/10 12:52 PM, Franz Koch wrote:
> Hey Sebastiaan,
>
>> Thanks for the reply, the structure is indeed the second scenario, a
>> employee knows about the department. Would you be able to give me some
>> sample code on how this would work with the groupedForViewHelper?
>>
>> Im hoping this would help me get this done, because it is just taking to
>> much time figuring this stuff out.
>
> This is a example from the doc comment of the groupedForViewHelper:
>
> * <ul>
> * <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>
>
> Mapping this to your extension would look like this (untested though):
>
> ----------------------------------------------------------
> In your Controller:
> ----------------------------------------------------------
> $employeeRepository =
> $this->objectManager->get('Tx_YourExt_Domain_Repository_EmployeeRepository');
>
> $this->view->assign('employees', $employeeRepository ->findAll());
>
> ----------------------------------------------------------
> In Fluid:
> ----------------------------------------------------------
> <dl class="employeeList">
> <f:groupedFor each="{employees}" as="employeesByDepartment"
> groupBy="department" groupKey="department">
> <dt>{department.name}</dt>
> <dd>
> <ul>
> <f:for each="{employeesByDepartment}" as="employee">
> <li>{employee.name}</li>
> </f:for>
> </ul>
> </dd>
> </f:groupedFor>
> </dl>
>
>
>
>
> Something like this I think. I personally didn't work with the
> groupedFor viewHelper yet as I was not in need of it, so I'm not
> entirely sure if it can handle this as intended.
>

Thnx for the quick replies, ill try to implement your code.


More information about the TYPO3-project-typo3v4mvc mailing list