tree_count

Summary

Counts the objects returned from the tree function.

Usage

fetch( 'content',
       'tree_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',     boolean,            ]
           [ 'depth',              depth,              ]
           [ 'depth_operator',     depth_operator      ] ) )

Parameters

NameTypeDescriptionRequired
parent_node_id integer The node to count children from. Yes.
class_filter_type string Type of filtering (include/exclude). No.
class_filter_array array Filter: array of class ID's or identifier strings. No.
attribute_filter mixed Attribute filter information. No.
main_node_only boolean Count only main nodes or all nodes. No.
depth integer Max level of depth to explore. No.
depth_operator string Logic to use when checking the depth. No.

Returns

Integer (number of nodes).

Description

This fetch function is almost the same as the "tree" fetch function. The difference is that it simply counts and returns the number of nodes that were fetched from within a branch of the content node tree. In other words, it does not return an array with the actual nodes, only an integer is returned.

This function takes the same parameters as the list fetch function except of the parameters that control the sorting/grouping mechanisms and the limit/offset parameters. Please refer to the documentation page for the list fetch function for a detailed description of the parameters. The "depth" and the "depth_operator" parameters are described in the documentation page for the tree function.

Examples

{let count=fetch( 'content', 

                 'tree_count', 

                 hash( 'parent_node_id',    42,

                       'depth',             2,

                       'class_filter_type', 'exclude',

                       'class_filter_array', array( 'folder', 'info_page' ) ) )}

 

Number of nodes: {$count}

{/let}

The example above counts the number of nodes that are children of node number 42. Only nodes that are within the range of depth 2 are counted. Nodes that are of type 'folder' or 'infopage' will be excluded from the count.

Comments

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:15:28 pm
by Balazs Halasy

Last updated

13/02/2004
4:35:44 pm
by Balazs Halasy

Authors

Balazs Halasy
Bård Farstad



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.