Project

General

Profile

Actions

Bug #78527

closed

Recursive iteration fails for repository results

Added by Morten Haggren about 8 years ago. Updated 6 months ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
Fluid
Target version:
-
Start date:
2016-11-01
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
7
PHP Version:
5.5
Tags:
Complexity:
Is Regression:
No
Sprint Focus:

Description

Trying to render a tree of categories where each category has a link to each parent.

The action sets the fluid variable categories, like so

$this->view->assign('categories', $this->categoryRepository->findAll());

The fluid template

<f:layout name="Default" />
<f:section name="main">
Menu 1:
    <f:render section="categoryTree" arguments="{categories:categories, parent:0, selected:selected.uid}" />
Menu 2:
    <f:render section="categoryTree" arguments="{categories:{ 0:{ parent:{ uid:5 }, uid:7, name:'1a' } 1:{ parent:{ uid:5 }, uid:6, name:'1b' } 2:{ parent:{ uid:0 }, uid:5, name:'1' } 3:{ parent:{ uid:1 }, uid:4, name:'2a' } 4:{ parent:{ uid:1 }, uid:3, name:'2b' } 5:{ parent:{ uid:0 }, uid:1, name:'2' } 6:{ parent:{ uid:1 }, uid:2, name:'2c' } }, parent:0, selected:selected.uid}" />    
</f:section>

<f:section name="categoryTree">
    <ul>
        <f:for each="{categories}" as="category">        
            <f:if condition="{category.parent.uid}=={parent}">        
                <li>
                    {category.name}
                    <f:render section="categoryTree" arguments="{categories:categories, parent:category.uid}" />
                </li>
            </f:if>
        </f:for>
    </ul>
</f:section>

This renders;

Menu 1 :
1
  1a

Menu 2:
1
  1a
  1b
2
  2a
  2b
  2c

By the look of things when passing an object rather than JSON (derived from said object) it remembers it's iterative state from child recursions and so only prints out the first branch.

Actions

Also available in: Atom PDF