ez.no / exponential / documentation / reference / data fetching / content / tree_count
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 ] ) )
| Name | Type | Description | Required |
|---|---|---|---|
| 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. |
Integer (number of nodes).
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.
{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