[TYPO3-mvc] Fluid List Item Issue

Sebastiaan van Parijs svparijs at bkwi.nl
Wed Dec 29 11:23:41 CET 2010


On 12/28/10 4:27 PM, Franz Koch wrote:
> Hey Sebastiaan,
>
>> The example:
>>
>> Department1
>> Employee1
>> Employee2
>> Department2
>> Employee3
>> Employee4
>> Employee5
>> Etc.
>>
>> This is what im trying to get with LI's in html, but i dont have a clue
>> how to get this out of the repository, and how to put it through Fluid
>> and get the results i want. (See example)
>>
>> Any suggestions?
>
> This depends on your data structure. Do your departments have a
> "employees" property where all employees of that department are
> assigned? If that's the case, do the following:
>
> ----------------------------------------------------------
> In your Controller:
> ----------------------------------------------------------
> // assuming you use a SVN version you can use the objectManager to
> create instances like below.
> // if you're working with a TER version you should use
> t3lib_div::makeInstance instead (for now)
> $departmentRepository =
> $this->objectManager->get('Tx_YourExt_Domain_Repository_DepartmentRepository');
>
> $this->view->assign('departments', $departmentRepository->findAll());
>
> ----------------------------------------------------------
> In Fluid:
> ----------------------------------------------------------
> <dl class="employeeList">
> <f:for each="{departments}" as="department">
> <dt>{department.name}</dt>
> <dd>
> <ul>
> <f:for each="{department.employees}" as="employee">
> <li>{employee.name}</li>
> </f:for>
> </ul>
> </dd>
> </f:for>
> </dl>
>
>
> For the case that only your employees know about the department they are
> working in you should have a look at the groupedForViewHelper which is
> first grouping your employees by department and then iterating over
> them, allowing the same logic like above.
>
> If it's still unclear how to do, please give more information about your
> models and how those are related to each other.
>
> Hope that helps.
>

Hey Franz,

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.

Thnx,
Sebastiaan van Parijs


More information about the TYPO3-project-typo3v4mvc mailing list