{tree:item_ids:relation_field:reverse:sort_string:slices}

Description

Returns the long ids of all items in the tree under a root item, found by following a relation field from parent to child. The root id is always included, then each item below it, walked depth-first and joined with a dash. Pass several root ids (dash-separated) to walk more than one tree at once; the combined list is de-duplicated. The result is a plain id list you feed into view or item to render a section together with its sub-pages, or into count to size a branch. The default relation field is relation........ ; set the third parameter to 1 for a reverse tree (the field points child to parent), and the fifth to restrict the walk to listed slices. Related: treestring returns the same tree as a nested string, path returns the ids from the root down to one item, and menu builds an HTML navigation menu.

Parameters

item_ids required default (none)

Long or short id of the tree root - the item whose subtree you want. Pass several ids separated by a dash to walk more than one root; their ids are merged and de-duplicated. The root id is always included in the result.

relation_field optional default relation........

The relation field that links a parent item to its child items. Defaults to relation........ - change it only when your tree is built on a different relation field.

reverse optional default (empty = forward)

Set to 1 for a reverse tree, where the relation field points from child to parent (each item names its parent) instead of parent to child. A reverse tree is limited to the slice of the root id.

sort_string optional default (none)

Orders the items within the tree, in the same format as a view sort (for example sort[0][headline........]=a). It currently takes effect only for reverse trees.

slices optional default (all slices)

Dash-separated list of slice ids the walk is allowed to enter. Items in other slices are skipped. Leave empty to follow the relation into any slice.

Examples

virtual{tree:1a2b3c4d5e6f70819293a4b5c6d7e8f9:relation........:::sliceid1-sliceid2}
Expected(only subtree ids that live in the listed slices)
Actual1a2b3c4d5e6f70819293a4b5c6d7e8f9
The fifth parameter is a dash-separated list of slice ids. Items in other slices are skipped, which is useful when one tree spans several slices and you want only part of it. Parameters three and four (reverse, sort) are left empty here.
virtual{view:12345:{tree:1a2b3c4d5e6f70819293a4b5c6d7e8f9}}
Expected(the view renders the root item and every item below it)
The everyday use: feed the subtree ids into {view} (or {item}) to display a section and all its sub-pages. Replace 12345 with your list view id and the id with a real root.
test{tree:a65d19971986e750761f0efcd9a16b1b}
Expecteda65d19971986e750761f0efcd9a16b1b
Actuala65d19971986e750761f0efcd9a16b1b
A node with no children returns just its own long id - the tree under a leaf is the leaf itself.
test[{tree:}]
Expected[]
Actual[]
With no root id there is nothing to walk, so the result is empty. Brackets show the empty output.
test{count:{tree:a65d19971986e750761f0efcd9a16b1b}}
Expected1
Actual1
Feed the dash-joined ids into {count} to size a branch. A leaf subtree has one item - itself.
test{tree:a65d19971986e750761f0efcd9a16b1b-4f3362a62847fe1f8c59ba28a92d42c0}
Expecteda65d19971986e750761f0efcd9a16b1b-4f3362a62847fe1f8c59ba28a92d42c0
Actuala65d19971986e750761f0efcd9a16b1b-4f3362a62847fe1f8c59ba28a92d42c0
Pass a dash-separated list of root ids. Each subtree is walked and all ids are joined with a dash.
test{ifeq:{tree:a65d19971986e750761f0efcd9a16b1b}:{tree:a65d19971986e750761f0efcd9a16b1b:relation........}:same:different}
Expectedsame
Actualsame
Omitting the second parameter is the same as passing relation........ - the default tree relation field.
test{tree:a65d19971986e750761f0efcd9a16b1b-a65d19971986e750761f0efcd9a16b1b}
Expecteda65d19971986e750761f0efcd9a16b1b
Actuala65d19971986e750761f0efcd9a16b1b
The same id reached twice appears once - the result is de-duplicated.
virtual{tree:1a2b3c4d5e6f70819293a4b5c6d7e8f9}
Expected(the root id, then each descendant id below it, dash-joined, walked depth-first)
Actual1a2b3c4d5e6f70819293a4b5c6d7e8f9
When the root has children linked through relation........, the result is the root followed by every item beneath it. Replace the id with a real parent in your slice. Depth-first order: a parent comes before its own children.
virtual{tree:1a2b3c4d5e6f70819293a4b5c6d7e8f9:relation.......1}
Expected(ids of the subtree built from the relation.......1 links)
Actual1a2b3c4d5e6f70819293a4b5c6d7e8f9
The second parameter names the relation field that links parent to child. Use it when your tree is not on the default relation........ field.
virtual{tree:1a2b3c4d5e6f70819293a4b5c6d7e8f9:relation........:1}
Expected(ids of every item that points up to this one, and so on down the branch)
Actual1a2b3c4d5e6f70819293a4b5c6d7e8f9
Set the third parameter to 1 for a reverse tree, where the relation field points child-to-parent (each item names its parent). A reverse tree is limited to the root id's own slice.