[TYPO3-mvc] Get childs

Felix Eggbert eggbert at phez.com
Mon Jan 24 13:38:26 CET 2011


Hi,

I have a similar problem. In my case the relation is the other way around:
many categories have either none or exactly 1 parent category (1:n). But how
can I determine the children of a category? 

I have already set up a repository function that would find all children of
the given category:
 
public function findAllChildren(Tx_MyExt_Domain_Model_Category $category) {
    $query = $this->createQuery();
    $query->matching($query->equals('parent', $category));
    return $query->execute();
  }

I've also implemented a getter in my model that calls this repository
function:

public function getChildren() {
    $categoryRepository =
t3lib_div::makeInstance('Tx_MyExt_Domain_Repository_CategoryRepository');
    $children = $categoryRepository->findAllChildren($this);
    return clone $children;
  }

But how can I access this getter from Fluid?

I think I am close to it. 

 
Thanks and regards,

Felix



-----Ursprüngliche Nachricht-----
Von: typo3-project-typo3v4mvc-bounces at lists.typo3.org
[mailto:typo3-project-typo3v4mvc-bounces at lists.typo3.org] Im Auftrag von
Dawid Pacholczyk
Gesendet: Freitag, 22. Oktober 2010 12:37
An: TYPO3 v4 MVC project
Betreff: Re: [TYPO3-mvc] Get childs

Ok. Thank you Dennis. Now I understand. I have wrong relation :) Every day I
learn something new hehe

I`ll implement all info from you and give you feedback how it went.

Best regards,
Dawid Pacholczyk

2010/10/22 Dennis Ahrens <dennis.ahrens at googlemail.com>

> Hey,
>
>
> Dawid Pacholczyk wrote:
>
>> Thank you Franz I`ll test in a moment
>>
>> My scenario is simple. I want to create something like a tree
>>
>> We have main block. Every block can have his own subblocks. Every 
>> subblock can have his own subsubblocks.
>>
>> Thats why subsubblock can`t be connected with main block. I`ve 
>> already displayed it like I wanted to but I`m wondering - thats why 
>> we`re talking atm - is there a buildin fluid method for this kind of
operations.
>>
>> Maybe I`m steal pi_base oriented cause I`m learning the extbase and 
>> some habbits may stay in my way and documentation is poor but your 
>> knowlage is awsome :)
>>
>
> ok - your model looks like this than:
>
> Block with mm-relation to Block -> each Block can have several blocks 
> as child.
>
> - BlockA
>  - BlockB
>  - BlockE
>  - BlockC
>  - BlockD
>
> If each layer should look the same - the above mentioned solutions are 
> possible.
>
> Write your partial like Franz posted it related to your model.
> The partial is than executed recursively for each block of your tree 
> with depth first. Related to the example structure above:
> BlockA -> BlockB -> BlockE -> BlockC -> BlockD
>
> regards
> Dennis
>
>
> _______________________________________________
> TYPO3-project-typo3v4mvc mailing list
> TYPO3-project-typo3v4mvc at lists.typo3.org
> http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-project-typo3v4m
> vc
>



--
Dawid Pacholczyk
tel: 502-054-334
gg: 5564051
skype: dpacholczyk
http://typo3blog.pl (only polish version at the moment)
_______________________________________________
TYPO3-project-typo3v4mvc mailing list
TYPO3-project-typo3v4mvc at lists.typo3.org
http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-project-typo3v4mvc



More information about the TYPO3-project-typo3v4mvc mailing list