Query on fetch children

Author Message

Toms King

Monday 14 August 2006 9:13:43 pm

Hi, all,

I am new to use eZpublish to develop CMS, and now I face a problem.

{default attribute_base=ContentObjectAttribute container="fieldset"}
<{$container}>
{* parent_node is default_selection_node or root *}
{let class_content=$attribute.contentclass_attribute.content
parent_node=cond(and(is_set($class_content.default_selection_node),$class_content.default_selection_node|eq(0)|not),$class_content.default_selection_node,1)

nodesList=cond(and(is_set($class_content.filter_class),$class_content.filter_class|eq(0)|not),
fetch( content, tree,
hash( parent_node_id, $parent_node,
class_filter_type,'include',
class_filter_array, array($class_content.filter_class),
sort_by, array('name',true()),
main_node_only, true() ) ),
fetch( content, list,
hash( parent_node_id, $parent_node,
sort_by, array('name',true())
) )
)

}

{section var=node loop=$nodesList}
{$node.name|wash} {$node.contentobject_id|wash}
{/section}

This part of codes will bring me an array named nodesList who is the children of parent_node.

and now I wanna get the children of every node in nodesList. Thus, I edit the section part,

{section var=node loop=$nodesList}
{$node.name|wash} {$node.contentobject_id|wash}

{
subnodesList = fetch( content, list,
hash( parent_node_id, $node,
sort_by, array('name',true())
) )
}

{section var=subnode loop=$subnodesList}
{$subnode.name|wash} <br/>

{/section}
{/section}

However, the result show that the adding part
{
subnodesList = fetch( content, list,
hash( parent_node_id, $node,
sort_by, array('name',true())
) )
}

{section var=subnode loop=$subnodesList}
{$subnode.name|wash} <br/>

{/section}
didn't work, why? Thank you very much for your attention.

Best regards

Toms

Claudia Kosny

Tuesday 15 August 2006 10:47:11 am

Hello Toms,

most likely the problem is that you do not use the node_id, but the node itself as parameter for the fetch function for subnodeslist.

Apart from that I would use the foreach statement instead of section loop. You need less code and IMO it is much clearer which variable holds which information. So the relevant part of your code would look like ( this is not tested...):

{def $subNodesList=array()}
{foreach $nodesList as $currentNode}
  {$currentNode.name|wash} {$currentNode.contentobject_id|wash} <br />
  {set $subNodesList = fetch( content, list, hash( parent_node_id, $currentNode.node_id,
                                                                       sort_by, array('name',true())))}

  {foreach $subNodesList as $subNode}
   {$subNode.name|wash} <br />
  {/foreach}
{/foreach}

One last thing: When posting here please surround your code examples with code tags (you can see an example on the righthand side when you write a post). This makes it much easier to tell the code apart from the question.

greetings from Luxembourg

Claudia

Toms King

Tuesday 15 August 2006 6:32:27 pm

thx, Claudia, got it

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 18 2025 19:35:33
Script start
Timing: Jan 18 2025 19:35:33
Module start 'layout'
Timing: Jan 18 2025 19:35:33
Module start 'content'
Timing: Jan 18 2025 19:35:34
Module end 'content'
Timing: Jan 18 2025 19:35:34
Script end

Main resources:

Total runtime0.6675 sec
Peak memory usage4,096.0000 KB
Database Queries57

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0056 589.0234152.6250
Module start 'layout' 0.00560.0027 741.648439.4453
Module start 'content' 0.00840.6578 781.0938484.4219
Module end 'content' 0.66610.0013 1,265.515612.1719
Script end 0.6675  1,277.6875 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00340.5134160.0002
Check MTime0.00140.2110160.0001
Mysql Total
Database connection0.00080.122410.0008
Mysqli_queries0.611091.5252570.0107
Looping result0.00060.0884550.0000
Template Total0.632894.820.3164
Template load0.00270.397020.0013
Template processing0.630194.395120.3151
Template load and register function0.00030.040910.0003
states
state_id_array0.00280.424410.0028
state_identifier_array0.00140.214420.0007
Override
Cache load0.00220.3297680.0000
Sytem overhead
Fetch class attribute can translate value0.00080.113320.0004
Fetch class attribute name0.00190.280630.0006
XML
Image XML parsing0.00030.040820.0001
class_abstraction
Instantiating content class attribute0.00000.002430.0000
General
dbfile0.00070.1072100.0001
String conversion0.00000.001040.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
11content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
7content/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: 24
 Number of unique templates used: 6

Time used to render debug report: 0.0001 secs