[TYPO3-mvc] Fluid List Item Issue

Dawid Pacholczyk dpacholczyk at gmail.com
Wed Dec 29 08:49:36 CET 2010


W dniu 2010-12-28 16:27, Franz Koch pisze:
> 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.
>

Hello,
  I have small question to this example. Is this code (I mean the 
controller) should go to departmentController ? If yes why we are 
creating new repository ? Every controller has a repository to his 
model. So why we`re creating new one ? Or meybe it should go to other 
controller ?

Best regards,
Dawid Pacholczyk


More information about the TYPO3-project-typo3v4mvc mailing list