[TYPO3-mvc] Get childs
Dennis Ahrens
dennis.ahrens at googlemail.com
Fri Oct 22 09:00:24 CEST 2010
Hi Dawid,
Dawid Pacholczyk wrote:
> Hello List,
>
> I`m wondering about one thing. I have a model "BLOCK". Block is some object
> with content. Every block can have subblock, every subblock can have
> subsubblock and go on.
>
>
>
> Now. I can get childs using recurrence. BUT my question is. Does extabse got
> internal system to manage this ? For example we have
> $this->someRepository->findAll(); Is there something similar for getting
> childs ? Is there a way to use recurrence in fluid template ?
I have a similar model - a DocumentTemplateElement has a mm-relation to
itself to set up a tree structure. I've solved the rendering by using a
partial that looks like this:
<f:if condition="{element}">
<f:then>
<ul>
<f:for each="{element.elements}" as="ele">
<f:render partial="DocumentTemplateElement" arguments="{element: ele}" />
</f:for>
</ul>
</f:then>
<f:else>
Error - no element given
</f:else>
</f:if>
You normally do not need a repository for fetching the childs. You
access them through the root object. $subblocks = $myblock->getSubblocks();
If you have to fetch them from repository, you may write a special
query, that checks if the object is associated as uid_foreign in your
mm-table. Or you add a depth property to your model, that you can ask
via SQL.
regards
Dennis
More information about the TYPO3-project-typo3v4mvc
mailing list