Display grandchildren/subheadings on page

Author Message

David Hupp

Thursday 19 October 2006 6:11:32 pm

How would I go about displaying a node so that the node's grandchildren are displayed in addition to its children?

For example, I want a page that looks like:

http://stuff.belvederedesign.net/Example1.png

Rather than:

http://stuff.belvederedesign.net/Example2.png

or,

http://stuff.belvederedesign.net/Example3.png

Where 'Food I Like' is the parent; 'Fruit', 'Vegetables', and 'Sweets' are the children; and the bullets are the grandchildren. (I really don't care how the tree looks, I just care that the final output works, and is updated dynamically.)

I know that I can do this by 'not showing contents', and linking the contents manually in the description field, but this solution is less than optimal.

Would I do this in templates, or elsewhere? Any suggestions?

Claudia Kosny

Friday 20 October 2006 3:43:32 am

Hi David

Just change the full view template for the folder and for each child add an additional fetch for the children of this child.

Very basic template:

{* $node contains the node of the folder you are currently viewing *}
{* display name and description *}

<h1>{$node.data_map.name.content|wash()}</h1>

{if $node.data_map.short_description.content.is_empty|not}
 <div class="attribute-short">
  {attribute_view_gui attribute=$node.data_map.short_description}
 </div>
 {/if}
{if $node.data_map.description.content.is_empty|not}
 <div class="attribute-long">
  {attribute_view_gui attribute=$node.data_map.description}
 </div>
{/if}

{* fetch the direct children *}
{def $children = fetch('content', 'list', hash('parent_node_id', $node.node_id,
                                                            'sort_by', $node.sort_array))}
{if $children}
<ul>
 {foreach $children as $child}
 <li><a href={$child.url_alias|ezurl()}>{$child.name|wash}</a>
 {* now fetch the children of this child *}
 {def $grandchildren =  fetch('content', 'list', hash('parent_node_id', $child.node_id,
                                                                      'sort_by', $child.sort_array))}
 {if $grandchildren}
 <ul>
  {foreach $grandchildren as $grandchild}
   <li><a href={$grandchild.url_alias|ezurl()}>{$grandchild.name|wash} </a></li>
  {/foreach}
 </ul>
 {/if}
 {undef $grandchildren}
</li>
 {/foreach}
</ul>
{/if}

Health warning: This code may contain typos and other errors.

Greetings from Luxembourg

Claudia

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 15:02:58
Script start
Timing: Jan 18 2025 15:02:58
Module start 'layout'
Timing: Jan 18 2025 15:02:58
Module start 'content'
Timing: Jan 18 2025 15:02:59
Module end 'content'
Timing: Jan 18 2025 15:02:59
Script end

Main resources:

Total runtime1.2926 sec
Peak memory usage4,096.0000 KB
Database Queries54

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0044 588.0469152.6406
Module start 'layout' 0.00440.0032 740.687539.4766
Module start 'content' 0.00761.2833 780.1641461.7656
Module end 'content' 1.29080.0017 1,241.92978.1250
Script end 1.2926  1,250.0547 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00320.2484160.0002
Check MTime0.00140.1045160.0001
Mysql Total
Database connection0.00070.052510.0007
Mysqli_queries1.247896.5338540.0231
Looping result0.00060.0439520.0000
Template Total1.257597.320.6287
Template load0.00200.153820.0010
Template processing1.255597.128620.6277
Template load and register function0.00020.011710.0002
states
state_id_array0.00120.092610.0012
state_identifier_array0.00180.137320.0009
Override
Cache load0.00160.1240210.0001
Sytem overhead
Fetch class attribute can translate value0.00070.052120.0003
Fetch class attribute name0.00110.084920.0005
XML
Image XML parsing0.00020.018720.0001
class_abstraction
Instantiating content class attribute0.00000.000520.0000
General
dbfile0.00160.1275100.0002
String conversion0.00000.000540.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
2content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
3content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.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: 8
 Number of unique templates used: 5

Time used to render debug report: 0.0001 secs