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.

eZ debug

Timing: Jan 31 2025 01:14:49
Script start
Timing: Jan 31 2025 01:14:49
Module start 'layout'
Timing: Jan 31 2025 01:14:49
Module start 'content'
Timing: Jan 31 2025 01:14:49
Module end 'content'
Timing: Jan 31 2025 01:14:49
Script end

Main resources:

Total runtime0.5619 sec
Peak memory usage8,192.0000 KB
Database Queries57

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0051 588.1250151.2109
Module start 'layout' 0.00510.0047 739.3359220.6875
Module start 'content' 0.00970.5514 960.02344,222.3359
Module end 'content' 0.56120.0007 5,182.359411.8516
Script end 0.5619  5,194.2109 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00370.6546160.0002
Check MTime0.00140.2443160.0001
Mysql Total
Database connection0.00080.141810.0008
Mysqli_queries0.468683.4045570.0082
Looping result0.00040.0689550.0000
Template Total0.510890.920.2554
Template load0.00230.411620.0012
Template processing0.508490.488620.2542
Template load and register function0.00140.242210.0014
states
state_id_array0.00080.135310.0008
state_identifier_array0.00060.104020.0003
Override
Cache load0.00200.3550570.0000
Sytem overhead
Fetch class attribute can translate value0.00170.309520.0009
Fetch class attribute name0.01041.857530.0035
XML
Image XML parsing0.00020.035020.0001
class_abstraction
Instantiating content class attribute0.00000.001730.0000
General
dbfile0.00190.3395100.0002
String conversion0.00000.001640.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
3content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
6content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
3content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 15
 Number of unique templates used: 6

Time used to render debug report: 0.0001 secs