Get page child item count?

Author Message

Edward Eliot

Monday 04 October 2004 2:48:20 am

How do I get the child item count for my page class? I want to know whether or not I need to display related pages with a section=show tag.

The code to optionally display is:

<hr />
<br />
<h1>
	Related Pages
</h1>
<table class="page">
{section name=folder loop=fetch('content','list',hash(parent_node_id, $node.node_id, "sort_by", array("name", true())))}
	<tr>
	       {section show=is_set($folder:item.data_map.image)}
		      <td valign="top">
			      {attribute_view_gui attribute=$folder:item.data_map.image}
		      </td>
	       {/section}
	       <td valign="top">
		       <h2>
		       <a href={concat("/content/view/full/", $folder:item.node_id,"/")|ezurl} class="page">{$folder:item.name|wash}</a>
			</h2>
			{$folder:item.data_map.body.data_text|intro|wash|shorten(300)}
		</td>
	</tr>
{/section}
</table>

Frederik Holljen

Monday 04 October 2004 4:39:31 am

It's the count of that fetch you want right? Can't you just fetch in into a variable with let and then use array_count on it?

Mark Marsiglio

Monday 04 October 2004 4:56:18 am

I handled the related items this way:

{let related=$node.object.data_map.keywords.content.related_objects}
{section show=$related}

 {switch match=$related}
 {case match=''}

 {/case}
 {case}
<h3>Related documents</h3> 
{/case}
 {/switch}
<ol>
{section name=Related loop=$related}
<li class="relateditem"><a href={$:item.url_alias|ezurl}>{$:item.name}</a> <span class="relateditemclass"><nobr>{$node.object.class_name|wash}</nobr></span></li>
{/section}
</ol>
{/section}
{/let}

This tells the section title (related objects) to display only if there are items under it.

Another way to do it would be to repeat your fetch for related items but substitute list_count for list, and assign that to a variable.

...count=fetch('content','list_count',hash(parent_node...

This will return the total number of items that match the fetch criteria which you can use in a section show command.

http://www.thinkcreative.com
Turning Ideas Into Strategic Solutions

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

Main resources:

Total runtime0.8682 sec
Peak memory usage4,096.0000 KB
Database Queries59

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0047 592.7031152.6250
Module start 'layout' 0.00470.0030 745.328139.4453
Module start 'content' 0.00770.8589 784.7734578.0156
Module end 'content' 0.86660.0016 1,362.789112.1641
Script end 0.8682  1,374.9531 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00330.3770160.0002
Check MTime0.00130.1509160.0001
Mysql Total
Database connection0.00070.075910.0007
Mysqli_queries0.816894.0752590.0138
Looping result0.00060.0677570.0000
Template Total0.838696.620.4193
Template load0.00250.288920.0013
Template processing0.836196.297820.4181
Template load and register function0.00030.033710.0003
states
state_id_array0.00110.127510.0011
state_identifier_array0.00120.139020.0006
Override
Cache load0.00180.2116170.0001
Sytem overhead
Fetch class attribute can translate value0.00120.139430.0004
Fetch class attribute name0.00110.125550.0002
XML
Image XML parsing0.00110.127630.0004
class_abstraction
Instantiating content class attribute0.00000.001250.0000
General
dbfile0.00100.1137210.0000
String conversion0.00000.000840.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
5content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
3content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.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: 15
 Number of unique templates used: 6

Time used to render debug report: 0.0001 secs