Printing Sub-folders content...

Author Message

Francis Poézévara

Thursday 19 July 2007 2:26:40 am

Hello,

I have content organized like that :

Affaires (Folder)
-- Affaire 1 (Folder)
---- Description Affaire 1 (Affaire)
---- Lot 1 Affaire 1 (Lot)
---- Lot 2 Affaire 1 (Lot)
-- Affaire 2 (Folder)
---- Description Affaire 2 (Affaire)

I would like to make a homepage which prints the description of every Affaire (it means Affaires > Affaire 1 > Description Affaire 1 and Affaires > Affaire 2 > Description Affaire 2).

First, I made a page which prints the names of the folders (Affaire 1 and Affaire 2), and it works. Then I tried to see the descriptions. When I make that :
==================================================================================
{let children=fetch( content, list, hash( parent_node_id, $node.node_id,
sort_by, $node.sort_array,
class_filter_type, include,
class_filter_array, array( 'folder') ) )}
{section name=Child loop=$children}
{let sub_children=fetch( content, list, hash( parent_node_id, $Child:item.node_id,
sort_by, $Child:item.sort_array,
class_filter_type, include,
class_filter_array, array( 'affaire') ) )}
{section name=SubChild loop=$sub_children}
{node_view_gui view=line content_node=$SubChild:item}
{/section}
{/let}

{/section}
{/let}
=======================================================================================
It doesn't work. But when I put the second loop out of the first, like that :
=======================================================================================
{let children=fetch( content, list, hash( parent_node_id, $node.node_id,
sort_by, $node.sort_array,
class_filter_type, include,
class_filter_array, array( 'folder') ) )}
{section name=Child loop=$children}

{/section}
{/let}
{let sub_children=fetch( content, list, hash( parent_node_id, $Child:item.node_id,
sort_by, $Child:item.sort_array,
class_filter_type, include,
class_filter_array, array( 'affaire') ) )}
{section name=SubChild loop=$sub_children}
{node_view_gui view=line content_node=$SubChild:item}
{/section}
{/let}
======================================================================================

It prints the description of the last Child of the loop....

What did I wrong plz ?

Christian Johansen

Thursday 19 July 2007 1:00:57 pm

Your first try looks correct at least. Have you tried printing some of the variables in the loop and so on to see whats going on? Do you get any errors in your debug outout? Both let and section are deprecated structures. Try to do the same with def/set and foreach. It's alot easier to read as well:

{def $children=false()
        $grand_children=false()}
{set $children=fetch(content, list, hash(parent_node_id, $node.node_id,
                               sort_by, $node.sort_array,
                               class_filter_type, include,
                               class_filter_array, array( 'folder')))}
{foreach $children as $child}
    {set $grand_children=fetch(content, list, hash(parent_node_id, $child.node_id,
                                                   sort_by, $child.sort_array,
                                                   class_filter_type, include,
                                                   class_filter_array, array( 'affaire')))}
    {foreach $grand_children as $grand_child}
        {node_view_gui view=line content_node=$grand_child}
    {/foreach}
{/foreach}

Francis Poézévara

Tuesday 24 July 2007 7:02:36 am

Works fine with your solution ! thx !

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.