{itree:ids_string:top:content:delim:bottom}

Description

Renders a set of items arranged as a TREE. The first parameter is a tree string: a dash-separated list of item ids where parentheses mark children, for example Gamma(Beta-Kappa) means Gamma is the parent of Beta and Kappa. The remaining parameters are templates expanded once per node, reading that item with its field aliases such as _#HEADLINE (each node is bound as the current item, like inside item). For every parent node, top is printed before its children and bottom after them; the parent node itself prints no content, only its wrapper. For every leaf node, content is printed, and delim is inserted between siblings at the same level. itree is the tree-display sibling of item: same engine, but a more natural parameter order (top comes before content). Inside any template you may reference the sibling parameters as _#1 (top), _#2 (content), _#3 (delim) and _#4 (bottom), which is handy for nesting the content template inside top. A flat list with no parentheses, like Gamma-Beta, just prints content for each item joined by delim, with no top or bottom. Typical use is breadcrumb navigation built from a seo path, or a threaded discussion tree. The tree string is usually produced by treestring or by xid path. This expression is never cached because item data can change between requests.

Parameters

ids_string required default (empty - prints nothing)

The tree string: a dash-separated list of item ids where parentheses mark children, e.g. PARENT(CHILD1-CHILD2). A plain dash list with no parentheses is a flat list. Usually produced by treestring or xid path. Long or short ids both work; an empty value prints nothing.

top optional default (empty - nothing before children)

Template printed BEFORE a node's children, expanded reading that parent node (e.g. top reads the parent). Use it to open a wrapper or print the parent itself. A parent node never prints content - only top and bottom.

content optional default (empty - leaves print nothing)

Template printed for each LEAF node, expanded reading that item (e.g. content, _#ITEM_URL). This is what you usually want for a flat list or for the last segment of a breadcrumb.

delim optional default (empty - no separator)

Inserted BETWEEN sibling nodes at the same level. Spaces are preserved (parameters are not trimmed), so a delimiter like a comma-space works as written.

bottom optional default (empty - nothing after children)

Template printed AFTER a node's children, expanded reading that parent node. Pair it with top to close a wrapper you opened, e.g. top opens a tag and bottom closes it.

Examples

test{itree:4f3362a62847fe1f8c59ba28a92d42c0::_#HEADLINE::}
ExpectedBeta
ActualBeta
One id is just one leaf: only content is printed. The empty top and bottom (the two colons before content) are skipped.
test{itree:5726c2c6b035d7aab450d1794e9e90d7(4f3362a62847fe1f8c59ba28a92d42c0(ae1da231f3e5bc16496834a0711aa042)):_#HEADLINE / :_#HEADLINE:: }
ExpectedGamma / Beta / Kappa
ActualGamma / Beta / Kappa
A pure path Gamma(Beta(Kappa)) nests one child per level. Every node with children prints top (here _#HEADLINE / ), and the final leaf prints content (_#HEADLINE). The result is a breadcrumb. In production the path comes from xid path or treestring, not hand-written ids.
test[{itree:::_#HEADLINE::}]
Expected[]
Actual[]
An empty tree string returns an empty string (shown here between literal brackets so you can see there is no output).
test{itree:5726c2c6b035d7aab450d1794e9e90d7-4f3362a62847fe1f8c59ba28a92d42c0-ae1da231f3e5bc16496834a0711aa042::_#HEADLINE:, :}
ExpectedGamma, Beta, Kappa
ActualGamma, Beta, Kappa
With no parentheses the tree string is a plain list. content (_#HEADLINE here, the 3rd parameter) prints for each item and delim joins them; top and bottom stay empty.
virtual{itree:{treestring:{ids:9e1d2b9f88e3d6c3bf0eb967378610d6:::number..........}}:<li>_#HEADLINE<ul>:<li>_#HEADLINE</li>::</ul></li>}
Expected(nested
    /
  • menu markup)
Actual
  • Alpha
  • top opens a list item and a nested <ul> for each parent; content is a leaf <li>; bottom closes the <ul> and parent <li>. treestring turns a flat id list (or a parent-relation query) into the tree string. Marked illustrative because the output is HTML markup.
    test{itree:5726c2c6b035d7aab450d1794e9e90d7(4f3362a62847fe1f8c59ba28a92d42c0-ae1da231f3e5bc16496834a0711aa042):[:_#HEADLINE:, :]}
    Expected[Beta, Kappa]
    Actual[Beta, Kappa]
    Parentheses make Gamma the parent of Beta and Kappa. top ([) prints before the children, bottom (]) after, and delim (, ) between the two leaf children. The parent node prints no content of its own - only its wrappers.
    virtual{itree:{xid:path}: &gt; _#HEADLINK: &gt; _#HEADLINE}
    Expected(e.g. > Home > News > This article)
    The canonical production pattern. {xid:path} returns the tree string of the current item's section path; for each ancestor it prints top ( > _#HEADLINK, a linked headline), and for the current page it prints content ( > _#HEADLINE, plain text). Output depends on where the page sits in the site tree, so this is illustrative, not a fixed test.
    test{itree:5726c2c6b035d7aab450d1794e9e90d7(4f3362a62847fe1f8c59ba28a92d42c0-ae1da231f3e5bc16496834a0711aa042):[_#2]:_#HEADLINE:-:}
    Expected[Gamma]Beta-Kappa
    Actual[Gamma]Beta-Kappa
    Inside any template the sibling parameters are available as _#1 (top), _#2 (content), _#3 (delim), _#4 (bottom). Here top is [_#2], so it embeds the content template (_#HEADLINE) and prints the parent wrapped in brackets, without repeating the template text.
    test{itree:5726c2c6b035d7aab450d1794e9e90d7(4f3362a62847fe1f8c59ba28a92d42c0-ae1da231f3e5bc16496834a0711aa042):_#HEADLINE > :_#HEADLINE:, :}
    ExpectedGamma > Beta, Kappa
    ActualGamma > Beta, Kappa
    top is expanded for the parent node, so _#HEADLINE there reads the parent (Gamma). content reads each leaf. This is the building block of a breadcrumb.