ez.no / exponential / documentation / reference / data fetching / content / list_count
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, ] ) )
| Name | Type | Description | Required |
|---|---|---|---|
| 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. |
Integer (number of nodes).
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.
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}
Log in or create a user account to comment.
Comments