Skip to content

Core Concepts

Navigation separates menu configuration (how deep a menu can nest, its cache TTL, edit permission, and custom node fields) from menu items (the hierarchical tree of links and passive elements managed by editors).

flowchart LR
  Schema["Menu Schemas\nsite/navigation/*.yaml + DB\n(yaml | db | hybrid)"] --> Registry["MenuRegistry"]
  Registry --> Entries["Entries Storage\nnavigation-menus & navigation-node-{handle}"]
  Entries --> Builder["TreeBuilder + Target Adapters\npage · url · entry · children · passive"]
  Builder --> Cache["Two-Tier Cache\nIn-Memory + WireCache"]
  Cache --> Render["MarkupNavigation HTML\n& BreadcrumbList JSON-LD"]
  Cache --> Headless["Headless REST API\n/api/v1/navigation/*"]

Dual-Source Menu Schemas (yaml, db, hybrid)

Section titled “Dual-Source Menu Schemas (yaml, db, hybrid)”

MenuRegistry discovers menus from two sources and records each menu’s active $source:

  • yaml: Defined as a file in site/navigation/{handle}.yaml (or an extra path registered via $navigation->addPath()). Ideal for version-controlled menus with custom node fields:.
  • db: Created inside Setup -> Navigation -> New Menu (navigation-menus Entries collection) or via make:navigation --db. Ideal for client-managed landing-page or seasonal menus.
  • hybrid: A YAML-defined menu whose title, description, depth, cache TTL, or permission was overridden in the database while preserving its YAML custom fields:.

Navigation creates zero custom SQL tables. Instead, NavigationBlueprints registers hidden Entries collections (revisions: 10, sluggable: false):

  • navigation-menus: Stores database-backed menus and YAML menu overrides.
  • navigation-nodes: Default collection for menus without custom fields.
  • navigation-node-{handle}: Per-menu node blueprint generated automatically whenever a YAML menu defines custom fields: (for example, navigation-node-main with subtitle and badge_text).

Because Entries caps native entries_items.parent_id nesting at 2 levels on collections, Navigation tracks arbitrary tree depth (up to maxDepth: 10) using an indexed parent_node_id UUID string and node_depth integer maintained transactionally by NodeHierarchyManager.

When you query $navigation->tree('main') or $navigation->breadcrumbs($page), Navigation returns strongly typed, readonly value objects:

  • MenuDefinition: $handle, $title, $description, $icon, $maxDepth, $cacheTtl, $includeHiddenPages, $permission, $fields, $source, $hasInvalidPermission.
  • NavigationTree: Holds $menu plus nodes(), flatten(), findById(), findByPage(), activeNode(), activeTrail(), isEmpty(), count(), totalCount(), and toPublicArray().
  • NavigationNode: Holds $id, $type, $title, $description, $panelHandle, $icon, $url, $depth, $sort, $openNewTab, $isExternal, $isPassive, $passiveKind, $itemClasses, $linkClasses, $attributes, $visible, plus children(), parent(), ancestors(), isActive(), isActiveTrail(), iconSvg(), and getCustom().
  • NavigationBreadcrumbs & BreadcrumbItem: Holds ordered trail items with toArray() and toSchemaOrg() (BreadcrumbList).

NavigationTreeCache caches resolved trees in memory (per request) and in WireCache (Navigation::CACHE_NAMESPACE = 'navigation') for each menu’s cacheTtl (default 3600 seconds). PageSyncManager listens to ProcessWire Pages::* and Entries::* save, move, publish, trash, and delete hooks, calling invalidateForPage() and invalidateForEntry() automatically so menus never display stale titles, moved URLs, or unpublished pages.

Next steps