[TYPO3-mvc] Expandable items tree - how to make it with Fluid?

Ilya Kanunnikov ik at brosment.com
Sun Mar 6 13:45:52 CET 2011


Hi guys,
Please direct me to find right way.

I need to build expandable items tree. A need to assign special class (.act)
for all parent items of the selected item and expand them:

   1. Article 1 (active)
      1. Article 1.1 (active)
         1. *Article 1.1.1 (current)*
         2. Article 1.1.2
      2. Article 1.2
      3. Article 1.3
   2. Article 2
   3. Article 3


My current solution:

Partials/Article/articlesMenu (same partial used in recursion):

<f:if condition="{articles}">
> <ul>
> <f:for each="{articles}" as="article">
>  <li>
> <f:link.action controller="Article" action="show"
> arguments="{article:article}">{article.title}</f:link.action>
>  <f:render partial="Article/articlesMenu"
> arguments="{articles:article.childArticles}" />
> </li>
>  </f:for>
> </ul>
> </f:if>


 Code above works well for building fully-expanded tree, like sitemap. But I
need to expand tree if an article or its child article requested only. I
tried:

<f:if condition="{articles}">
> <ul>
> <f:for each="{articles}" as="article">
>  <li>
> <f:link.action controller="Article" action="show"
> arguments="{article:article}"><f:cObject
> typoscriptObjectPath="plugin.tx_snwarticlesplatform.viewHelpers.article.menuTitle">{article.title}</f:cObject></f:link.action>
>  <f:if condition="{article} == {activeArticle}"><f:render
> partial="Article/articlesMenu" arguments="{articles:article.childArticles}"
> /></f:if>
>  </li>
> </f:for>
> </ul>
> </f:if>


But code above works on the first level only so in case of article form
deeper level requested it doesn't expand the tree. It seems there should be
simple solution and I don't like complex one I could implement in controller
via multiple partials.

Is there any practice how to render expandable trees in Fluid? Please, give
some directions.

Thanks,
Ilya.


More information about the TYPO3-project-typo3v4mvc mailing list