{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 id of the page the visitor is on. A digit selects the ancestor at that directory level. The literal path gives the nested id path 2587(2877(3004)) for breadcrumbs; the literal list gives the dash-joined list 2587-2877-3004. 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 it returns an error. 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:param behaves the same as item with the current page id reading param.

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(id of the first-level item, e.g. 2587)
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 id path, e.g. 2587(2877(3004)))
Actual(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(dash-joined id list, e.g. 2587-2877-3004)
Actual-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}:_#HEAD_TIT}
Expected(a field of the current page, e.g. About the project)
Because xid returns the current page id, feed it to item to read any field of the page the visitor is on. This is the standard way to build a page title or heading from the page item itself. Page-dependent, so Illustrative.
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)
The canonical breadcrumb. xid:path feeds the nested id path into item, which renders each ancestor with the second template and joins them with the third. The result is a Home > Section > Page trail. Page-dependent, so Illustrative.
virtual{xid}
Expected(the current page item id, e.g. afbd7fdaa4dd6ae35ff7759f6faff580)
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.