Skip to content

pbMenu

Snippet to render a dynamic site menu. Generates a hierarchical menu from MODX resources, with full control over templates and nesting.

Parameters

ParameterDefaultDescription
parent0Comma-separated list of parent resource IDs to start from
tree1Whether to include child resources (1 = yes, 0 = no)
treeFieldparentField used to build the menu tree
level2Maximum depth of the recursive search
tplWrapper@INLINE <nav class="nav">{$items}</nav>Wrapper template for the entire menu
tplParent@INLINE <li class="nav-item dropdown"><a href="#" class="nav-link dropdown-toggle" role="button" data-bs-toggle="dropdown" aria-expanded="false" {$attributes}>{$menutitle ?: $pagetitle}</a><ul class="dropdown-menu">{$wrapper}</ul></li>Template for menu items with children
tpl@INLINE <li class="nav-item level-{$level}"><a class="nav-link{$resourse_id === $id ? " active": ""}" href="{$uri}" {$attributes}>{$menutitle ?: $pagetitle}</a></li>Template for a regular menu item
php
{'!pbMenu'|snippet}

© PageBlocks 2019-present