
pdoTools
Fast retrieval of site pages and users


Snippet for building breadcrumb navigation.
Replaces BreadCrumb well, works with documents from any contexts and allows specifying various conditions for resource selection.
Snippet has high performance by selecting all needed elements from the database in a single query.
Accepts all pdoTools parameters and some of its own:
| Parameter | Default | Description |
|---|---|---|
| &showLog | 0 | Log in a placeholder (since 3.0), not HTML. Requires mgr session. Details. |
| &from | 0 | Resource id from which to build breadcrumbs. Usually the site root, i.e. «0». |
| &to | Resource id for which breadcrumbs are built. Default is current page id. | |
| &exclude | List of resource IDs to exclude from selection. | |
| &toPlaceholder | If set, the snippet stores all data in a placeholder with this name instead of outputting. | |
| &outputSeparator | \n | Separator between crumbs |
| &tpl | Name chunk for displaying resource. If not set, resource fields will be printed to screen. | |
| &tplCurrent | Chunk for formatting current document in navigation. | |
| &tplMax | Chunk added at the start of results if there are more than &limit. | |
| &tplHome | Chunk for formatting link to home page. | |
| &tplWrapper | Wrapper chunk for all results. Accepts one placeholder: [[+output]]. Does not work with the parameter &toSeparatePlaceholders. | |
| &wrapIfEmpty | Enables wrapper chunk output &tplWrapper even when no results. | |
| &showCurrent | 1 | Output current document in navigation. |
| &showHome | 0 | Output link to home at start of navigation. |
| &showAtHome | 1 | Show breadcrumbs on the site home page. |
| &hideSingle | 0 | Don't output result if it is the only one. |
| &direction | ltr | Navigation direction: left to right «ltr» or right to left «rtl», e.g. for Arabic. |
Available in pdoTools 3.1.0+ (MODX 3)
Each crumb row gets these flags as 0 / 1. Existing &tpl / &tplCurrent / &tplHome chunks still apply.
| Placeholder | Meaning |
|---|---|
isFirst | First crumb in the list |
isLast | Last crumb in the list |
isActive | Crumb resource is the current page |
isHome | Crumb resource is the site start |
| Template | Default |
|---|---|
| &tpl | @INLINE <li><a href="[[+link]]">[[+menutitle]]</a></li> |
| &tplCurrent | @INLINE <li class="active">[[+menutitle]]</li> |
| &tplMax | @INLINE <li class="disabled"> ... </li> |
| &tplHome | |
| &tplWrapper | @INLINE <ul class="breadcrumb">[[+output]]</ul> |
Generate breadcrumbs for current page:
[[pdoCrumbs]]Generate with limit on number of items:
[[pdoCrumbs?
&limit=`2`
]]Snippet works well when called from pdoResources. For example, this chunk:
<h3>[[+pagetitle]]</h3>
<p>[[+introtext]]</p>
[[pdoCrumbs?
&to=`[[+id]]`
&showCurrent=`0`
]]Generate Schema.org microdata in JSON-LD format
{'!pdoCrumbs' | snippet: [
'showHome' => 1,
'tplWrapper' => '@INLINE
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "BreadcrumbList",
"itemListElement": [ {$output} ]
}
</script>
',
'tplHome' => '@INLINE
{
"@type": "ListItem",
"position": {$idx},
"item": {
"@id": "{$link}",
"name": "{$menutitle}"
}
},
',
'tplCurrent' => '@INLINE
{
"@type": "ListItem",
"position": {$idx},
"item": {
"@id": "{$link}",
"name": "{$menutitle}"
}
}
',
'tpl' => '@INLINE
{
"@type": "ListItem",
"position": {$idx},
"item": {
"@id": "{$link}",
"name": "{$menutitle}"
}
},
',
]}Working example of breadcrumb generation in search results mSearch2.
