Sidebar Logic

This page documents the current sidebar behaviour implemented by:

user/themes/members-hub/templates/partials/sidebar.html.twig

Purpose

The sidebar gives members a browsable page tree while keeping only the active branch open by default.

It is intended to support clarity, not to expose every page at once.

Top-Level Domains

The sidebar starts from the visible top-level Grav pages.

Rules:

  • The home route / is excluded.
  • Any page with sidebar_hide: true is excluded.
  • Pages are ordered by Grav folder order.
  • Each visible top-level page becomes a domain heading.

Examples of domains include:

  • Members
  • Operations
  • Governance
  • Archive
  • Site Admin

Expansion Behaviour

The sidebar is an accordion tree.

For each page:

  • If the page has visible children, it shows an expand/collapse button.
  • If the page is active, or contains the active page, its branch opens automatically.
  • Sibling branches close when a different branch at the same level is opened.
  • Child pages are rendered recursively down to the configured maximum depth.

Current maximum depth:

6

Directory Link

For each top-level domain, the sidebar attempts to add a "See more..." directory link at the bottom of the expanded branch.

The default directory route is:

/{domain}/{domain}-directory

This can be overridden in the domain landing page front matter:

sidebar_directory_route: /custom-directory-route
sidebar_directory_label: Directory

If the directory page is not found, no directory link is shown.

Hidden Pages

Any page can be removed from sidebar rendering with:

sidebar_hide: true

This applies to normal rendering and child expansion.

Reset Tree Button

The sidebar includes a Reset tree button.

It collapses all sidebar branches by adding the hidden state back to child containers and setting toggle buttons to aria-expanded="false".

The reset behaviour is supported by:

user/themes/members-hub/js/cc-reset-tree.js

Search Highlight Behaviour

When the Learn2 sidebar search highlights a matching navigation item, the sidebar opens the matched branch and its parent branches so the highlighted item is visible.

Front Matter Reference

Key Where used Purpose
sidebar_hide Any page Removes the page from sidebar rendering.
sidebar_directory_route Domain landing page Overrides the auto-detected directory link route.
sidebar_directory_label Domain landing page Overrides the default See more... directory label.

Notes

The current implementation does not use pinned pages or sidebar_pin ordering.

If pinned sidebar behaviour is introduced later, this page should be updated at the same time as the Twig template.