Forums / Setup & design / how do I output grandchildren of current node?

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

eZ debug

Timing: Jan 18 2025 22:17:48
Script start
Timing: Jan 18 2025 22:17:48
Module start 'content'
Timing: Jan 18 2025 22:17:48
Module end 'content'
Timing: Jan 18 2025 22:17:48
Script end

Main resources:

Total runtime0.0268 sec
Peak memory usage2,048.0000 KB
Database Queries4

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0104 589.2734180.8125
Module start 'content' 0.01040.0098 770.085997.9297
Module end 'content' 0.02020.0065 868.015674.7031
Script end 0.0267  942.7188 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002710.0781120.0002
Check MTime0.00114.1735120.0001
Mysql Total
Database connection0.00166.115510.0016
Mysqli_queries0.003111.519940.0008
Looping result0.00000.114820.0000
Template Total0.006022.610.0060
Template load0.00103.576210.0010
Template processing0.005118.960810.0051
Override
Cache load0.00072.587410.0007
General
dbfile0.003613.4131100.0004
String conversion0.00000.051630.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs