list_count

Summary

Counts and returns the number of children of a node.

Usage

fetch( 'content',
       'list_count',
       hash( 'parent_node_id',     parent_node_id,
           [ 'class_filter_type',  class_filter_type,  ]
           [ 'class_filter_array', class_filter_array, ]
           [ 'attribute_filter',   attribute_filter,   ]
           [ 'main_node_only',     main_node_only,     ] ) )

Parameters

NameTypeDescriptionRequired
parent_node_id integer ID number of the parent node. Yes.
class_filter_type string Type of class filtering (inclusion/exclusion). No.
class_filter_array array Type of nodes to include/exclude. No.
attribute_filter mixed Filter logic for attribute level filtering. No.
main_node_only integer Fetch all or only main node(s). No.

Returns

Integer (number of nodes).

Description

This fetch function is almost the same as the "list" fetch function. The difference is that it simply counts and returns the number of children for a node. In other words, it does not return an array with the actual nodes, only an integer is returned. The function takes the same parameters as the "list" function except of the parameters that control the sorting/grouping mechanisms and the limit/offset parameters. Please refer to the list function for a detailed description of the parameters.

Examples

Example 1
This example demonstrates how to count the number of children for node number 42. This is the most basic use of the "list_count" fetch function. As pointed out in the description, it is possible to do filtering, etc. Please refer to the examples for the list function to see how filtering can be done.

{* Get the number of children for node number 42. *}

{let node_count=fetch( 'content', 'list_count', hash( 'parent_node_id', 42 ) )}

 

   {* Display the number of child nodes. *}

   Node number 42 has {$node_count} number of children.

 

{/let}

Comments

Log in or create a user account to comment.

Contents

Reference

Database diagram
Template operators
Template functions
Data fetching
    Class
    Content
       access
       bookmarks
       can_instantiate_class_list
       can_instantiate_classes
       class
       class_attribute
       class_attribute_list
       collected_info_collection
       collected_info_count
       collected_info_count_list
       contentobject_attributes
       draft_count
       draft_version_list
       keyword
       keyword_count
       list
       list_count
       locale_list
       navigation_parts
       node
       non_translation_list
       object
       object_by_attribute
       object_count_by_user_id
       pending_count
       pending_list
       recent
       same_classattribute_node
       search
       section_list
       tipafriend_top_list
       translation_list
       trash_count
       trash_object_list
       tree
       tree_count
       version
       version_count
       version_list
       view_top_list
    Collaboration
    Layout
    Notification
    Package
    Section
    Shop
    URL
    User
Modules
XML tags


Created

06/02/2004
1:07:47 pm
by Balazs Halasy

Last updated

13/02/2004
3:25:50 pm
by Balazs Halasy

Authors

Balazs Halasy
B�rd Farstad
Wenyue Yu



This page is part of the Exponential documentation. The documentation is available under the GNU Free Documentation License. All contributions will be released under the terms of this license.