[TYPO3-dev] Object-Structure filtered by child object's owner

bernd wilke t3ng at bernd-wilke.net
Wed Aug 12 08:20:20 CEST 2015


Am 10.08.15 um 22:33 schrieb DirkHo:
> Hi all,
>
> I'm just creating my first extension and therefore I want to run over an
> object structure in fluid and recursively display all child objects of
> the "Main" object. E.g. the structure looks like:
>
> - Main
> -- Child 1
> --- Child of Child 1
> ----- OWNER: User 1
> --- Child of Child 2
> ----- OWNER: User 2
> --- Child of Child 3
> ----- OWNER: User 3
> -- Child 2
> --- Child of Child 1
> ----- OWNER: User 1
> -- Child 3
> --- Child of Child 1
> ----- OWNER: User 2
>
> For example I now want to filter the Main object to only fetch the child
> objects that are owned by User 1.
> Therefore I would expect the following structure to be returned:
>
> - Main
> -- Child 1
> --- Child of Child 1
> ----- OWNER: User 1
> -- Child 2
> --- Child of Child 1
> ----- OWNER: User 1
>
> The other Child and Child of Child objects should not be returned to
> fluid, because they are owned by other users.
>
> Is there a possibility to do so? I couldn't really find a good
> introduction to the query language used and by default the
> MainRepository does not have that much methods by default.
>
> Thanks and kind regards,
>
> Dirk

the problem might be the hierarchy which you want to hold while the 
query might result in an unordered list of pages involved.


as you have the user as source your query must start with him.
select all pages ehre the owner = current user
then you need to get the parents recursive:
while not root
   get parents of all pages on current level
   ascend level
endwhile

with all these pages you need to build up the tree again


another solution would be to have the logic in the output, but as it 
needs all data of the whole tree fluid might be to slow / memory hungry:
starting with the root:
for all childs:
    store page information of this level
    if current page has current user as owner:
      display all stored page informations (and clear them)
    else
      descend to childs
    endif
endfor

bernd
-- 
http://www.pi-phi.de/cheatsheet.html



More information about the TYPO3-dev mailing list