{xid[:level]}

Description

Returns the id of the current page item in a Site module, the counterpart to the xseo navigation variables. With no argument it gives the long id of the item the visitor's URL points to - on this reference that is the Reference item of the command being shown. A digit selects the ancestor at that directory level. The literal path gives the nested id path in the form the item command accepts, for example AAAA(BBBB(CCCC)) where each part is a 32-character long id - good for breadcrumbs; the literal list gives the same ids dash-joined, AAAA-BBBB-CCCC. A slice id returns the nearest ancestor page in that slice. Any other text is expanded as the content argument against the current page item. xid needs a Site module router, so its value depends on the current page; outside a router (for example in view.php) it returns an error message instead of an id. A second argument lets you ask about another url instead of the current page.

Parameters

param optional default (empty = current page id)

Optional. Selects which page-tree id you want. Leave empty for the current page id. A digit (1, 2, ...) gives the ancestor at that directory level. The literal value path returns the nested id path like 2587(2877(3004)) for breadcrumbs; list returns the dash-joined id list like 2587-2877-3004. A 32-character slice id returns the nearest ancestor page in that slice. Any other text is expanded as the content argument against the current page item, so xid:_#HEADLINE behaves the same as item with the current page id reading _#HEADLINE.

url optional default (empty = current page)

Optional. A url to report about instead of the current page. When given, xid resolves the level/path against that url rather than the page the visitor is on. Rarely needed; leave empty to describe the current page.

Examples

virtual{xid:1}
Expected(the long id of the item on the first URL level, 32 hex characters)
Actual8a5ae2c19dea766755b07c44c25d4540
A digit selects the ancestor page at that directory level. For /cz/project/about-us, xid:1 returns the id of the project page (the first level under the language root). Page-dependent, so Illustrative.
virtual{xid:path}
Expected(nested long ids from the top level down to the current page, e.g. 8a5ae2c19dea766755b07c44c25d4540(afbd7fdaa4dd6ae35ff7759f6faff580) on this page)
Actual8a5ae2c19dea766755b07c44c25d4540(afbd7fdaa4dd6ae35ff7759f6faff580)
The literal value path returns the whole branch as a nested id path, like 2587(2877(3004)). This is the exact shape item and itree expect, which makes it the building block for breadcrumbs. Page-dependent, so Illustrative.
virtual{xid:list}
Expected(the same long ids dash-joined, e.g. 8a5ae2c19dea766755b07c44c25d4540-afbd7fdaa4dd6ae35ff7759f6faff580 on this page)
Actual8a5ae2c19dea766755b07c44c25d4540-afbd7fdaa4dd6ae35ff7759f6faff580
The literal value list returns the same branch as a dash-joined list from the top of the tree to the current page, like 2587-2877-3004. Useful when you want to loop over the ancestors yourself. Page-dependent, so Illustrative.
virtual{xid:9e1d2b9f88e3d6c3bf0eb967378610d6}
Expected(id of the nearest ancestor in that slice, or empty)
Give a 32-character slice id and xid returns the id of the nearest page in the path that belongs to that slice, or empty if no ancestor does. Handy when several page types share one tree. Page-dependent, so Illustrative.
virtual{item:{xid}:_#HEADLINE}
Expected(the headline of the current page item - on this page the signature of xid)
Actual{xid[:level]}
Read any field of the page the visitor is on: pass the current id to item and use an alias of the page slice. On this reference the current page item is the Reference item, whose headline is the command signature.
virtual<a href="_#SEO_URL_" {ifeq:{xid:2}:{_#ITEM_ID_}:class="active"}>_#HEADLINE</a>
Expected(the matching link gets class="active")
A real-world menu pattern: inside a view that lists pages, compare the level you care about (here level 2) to each row item id with ifeq, and mark the matching link active. This is how site menus highlight the current section. Page-dependent, so Illustrative.
virtual{item:{xid:path}: _#HEADLINE:: _#HEADLINK >}
Expected(Home > Project > About the project)
Actual AA Expression Detail > {xid[:level]}
The canonical breadcrumb. xid:path feeds the nested id path into item, which renders each ancestor with the fourth argument (the nested-top template, a link plus >) and the current page with the second; the third, the delimiter, is empty. The result is a Home > Section > Page trail. Page-dependent, so Illustrative.
virtual{xid}
Expected(the long id of the current page item - on this page afbd7fdaa4dd6ae35ff7759f6faff580, the Reference item of xid)
Actualafbd7fdaa4dd6ae35ff7759f6faff580
The bare command returns the 32-character id of the item the visitor is currently on. Works only inside a Site module page; the value changes with every page, so this is Illustrative.