ez.no / exponential / documentation / reference / data fetching / content / tree
fetch( 'content',
'tree',
hash( 'parent_node_id', parent_node_id,
[ 'sort_by', sort_by, ]
[ 'offset', offset, ]
[ 'limit', limit, ]
[ 'attribute_filter', attribute_filter, ]
[ 'class_filter_type', class_filter_type, ]
[ 'class_filter_array', class_filter_array, ]
[ 'group_by', group_by, ]
[ 'only_translated', only_translated, ]
[ 'language', language, ]
[ 'main_node_only', main_node_only, ]
[ 'as_object', as_object, ]
[ 'depth', depth, ]
[ 'depth_operator', depth_operator ] ) )
| Name | Type | Description | Required |
|---|---|---|---|
| parent_node_id | integer | ID number of the parent node. | Yes. |
| sort_by | array | The type of sorting mechanism(s) to use. | No. |
| offset | integer | Offset to start at. | No. |
| limit | integer | Max number of nodes to fetch. | No. |
| attribute_filter | mixed | Filter logic for attribute level filtering. | No. |
| class_filter_type | string | Type of class filtering (inclusion/exclusion). | No. |
| class_filter_array | array | Type of nodes to include/exclude. | No. |
| group_by | array | Date/time-based grouping. | No. |
| only_translated | boolean | Fetch only translated objects. | No. |
| language | string | Language to use for translated objects. | No. |
| main_node_only | boolean | Fetch all or main nodes only. | No. |
| as_object | boolean | Return result as object or array. | No. |
| depth | integer | Max level of depth to explore. | No. |
| depth_operator | string | Logic to use when checking the depth. | No. |
Collection of nodes either as array or object.
The tree function is very similar to the list function and the parameters that occur in both functions are documented in the list documentation page. The only difference is that the tree function fetches child nodes recursively and the additional "depth" and "depth_operator" parameters. Please refer to the documentation page of the list function for a comprehensive explanation/description of the parameters.
Depth
The depth parameter can be used to specify the level of depth (within the branch) that the function should explore when it is running. If the depth is set to one, this function will simply act as the list function. If the depth is greater than one, the function will fetch nodes further down in the branch. In other words, the tree function makes it possible to fetch nodes from within a different levels of a branch in the content node tree.
Depth operator
If the depthoperator is set to 'eq', the function will only fetch nodes with the depth that was given using the depth parameter. By default, the function will fetch all nodes within the range (starting from the parent node) that was defined using the depth parameter. The default depth is unlimited, meaning that the function will drill down as far as possible.
Example 1
This example demonstrates how to fetch all the nodes that are under node number 42 recursively. This means that children, grand-children, etc. will be fetched. The name of the nodes are displayed.
{* Fetch everything that is under node #42 (children, grand-children, etc.) *} {let nodes=fetch( 'content', 'tree', hash( 'parent_node_id', 42 ) ) }<P>{* Loop through the nodes and display their names. *} {section loop=$nodes} {$:item.name}<br /> {/section}<P>{/let}
Comments