how do I output grandchildren of current node?

Author Message

Shaun Ellis

Monday 22 September 2003 1:43:21 pm

I have created three folder objects, each of which contain children objects. From the demo and examples I understand how to output the children of the current node. However, I want to display the "children's children" sort of like this:

{let children=fetch('content',list,hash(parent_node_id,$node.node_id))}
{section name=Child loop=$children}
<h2>{$Child:item.name}</h2>
{let grandchildren=fetch('content',list,hash(parent_node_id,$Child:node.node_id))}
{section name=grandchild loop=$grandchildren}
<a href="">{$grandchild:node.node_id}</a><br/>
{/section}
{/section}

Unfortunately, this doesn't work and I'm not sure what I'm doing wrong.

Thanks in advance for any help,
Shaun

Bjørn Kaarstein

Tuesday 23 September 2003 12:21:14 am

Have you tried :item.node_id instead of :node.node_id?

To check what is available, try {$Child:item|attribute(show)}
The |attribute(show) is excellent to check what you can access.

Regards Bjørn

Shaun Ellis

Thursday 25 September 2003 2:08:32 pm

Thanks for the tip... I edited my code a bit (see below) and tried using {$Folder:item|attribute(show)}. I can see there's an attribute for how many children the object has, but I can't seem to access their names. I can output the names of the children ($Folder) and a bullet for each of the grandchildren ($Child), but I can't seem to access any of the "grandchildren" attributes. When I try to use {$Child:item|attribute(show)} it comes back blank.

Here's my code:
------------------------
{let folder_list=fetch( content, list, hash(parent_node_id, 44,sort_by, array( array( priority ))))}
{section name=Folder loop=$folder_list}
{$Folder:item.name|wash}
<ul>
{section name=Child loop=fetch( 'content', 'list', hash(parent_node_id, $Folder:item.node_id, "sort_by", array("name", true())))}
<li><a class="small" href={concat( "/content/view/full/", $Child:item.node_id,"/" )|ezurl}>{$Child:item.name|wash}</a><br/></li>
{/section}
</ul>
{/section}
{/let}
------------------------

I get this error:

Unknown template variable 'item' in namespace 'Child'

-Shaun

Christian Lundvang

Friday 26 September 2003 12:47:22 am

Try to set {$Child:item.name} to {$:item.name}.

Hope this helsps

Christian

--
Best Regards
Christian Lundvang
http://www.nxc.no

Shaun Ellis

Friday 26 September 2003 7:48:38 am

Thank you! It worked, but I don't know why. I don't understand the logic of using the $Folder namespace successfully in the first section loop, but then leaving it blank in the nested section loop. Is there a documentation page that explains this better?

-Shaun

Dan Ruth

Tuesday 30 September 2003 8:17:33 am

Shaun, could you post your final working code? I am faced with a similiar problem, trying to access content attributes of child node. I can't figure out how you got your code to work...

Thanks,

Dan

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 06:19:17
Script start
Timing: Jan 31 2025 06:19:17
Module start 'layout'
Timing: Jan 31 2025 06:19:17
Module start 'content'
Timing: Jan 31 2025 06:19:19
Module end 'content'
Timing: Jan 31 2025 06:19:19
Script end

Main resources:

Total runtime1.2853 sec
Peak memory usage4,096.0000 KB
Database Queries70

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0062 588.2734151.2266
Module start 'layout' 0.00630.0027 739.500036.6797
Module start 'content' 0.00901.2753 776.17971,039.6641
Module end 'content' 1.28430.0009 1,815.843815.8125
Script end 1.2852  1,831.6563 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00340.2659160.0002
Check MTime0.00160.1210160.0001
Mysql Total
Database connection0.00090.070810.0009
Mysqli_queries1.209894.1301700.0173
Looping result0.00070.0545680.0000
Template Total1.250297.320.6251
Template load0.00230.182120.0012
Template processing1.247897.087620.6239
Template load and register function0.00140.112410.0014
states
state_id_array0.00160.121910.0016
state_identifier_array0.00180.142120.0009
Override
Cache load0.00190.1497510.0000
Sytem overhead
Fetch class attribute can translate value0.00050.038340.0001
Fetch class attribute name0.00220.174480.0003
XML
Image XML parsing0.00540.419440.0013
class_abstraction
Instantiating content class attribute0.00000.001480.0000
General
dbfile0.00660.5145220.0003
String conversion0.00000.000640.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
6content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
10content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
4content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
2content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.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.0002 secs