Files
structural_pages/templates/structural-pages-menu.html.twig
Quintino A. G. Souza 88b9605408 Rename module site_structure → structural_pages and vocabulary site_section → site_sections
Renames the module from site_structure to structural_pages and pluralizes
the taxonomy vocabulary machine name from site_section to site_sections,
updating all config, PHP, translations, and documentation references
while preserving field_site_section, clears_site_section, and $site_section_id.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-05 08:10:32 -03:00

64 lines
2.0 KiB
Twig

{#
/**
* @file
* Template for the structural pages menu block.
*
* Available variables:
* - ancestor: The ancestor entity (term, user, or group).
* - tree: Array of menu tree items, each containing:
* - id: Node ID.
* - title: Node title.
* - url: Node URL.
* - depth: Current depth level.
* - children: Array of child items.
* - entity: The node entity.
* - active_trail: Array of node IDs in the active trail.
* - show_ancestor_title: Whether to show the ancestor title as header.
*/
#}
{{ attach_library('structural_pages/menu') }}
{% if tree is not empty %}
<nav class="structural-pages-menu" aria-label="{{ 'Site structure navigation'|t }}">
{% if show_ancestor_title and ancestor %}
<h2 class="structural-pages-menu__title">
{% if ancestor.toUrl is defined %}
<a href="{{ ancestor.toUrl }}">{{ ancestor.label }}</a>
{% else %}
{{ ancestor.label }}
{% endif %}
</h2>
{% endif %}
<ul class="structural-pages-menu__list structural-pages-menu__list--level-1">
{% for item in tree %}
{{ _self.menu_item(item, active_trail, 1) }}
{% endfor %}
</ul>
</nav>
{% endif %}
{% macro menu_item(item, active_trail, depth) %}
{% set is_active = item.id in active_trail %}
{% set has_children = item.children is not empty %}
{% set classes = [
'structural-pages-menu__item',
'structural-pages-menu__item--level-' ~ depth,
is_active ? 'structural-pages-menu__item--active-trail',
has_children ? 'structural-pages-menu__item--has-children',
] %}
<li{{ create_attribute().addClass(classes) }}>
<a href="{{ item.url }}" class="structural-pages-menu__link{% if is_active %} structural-pages-menu__link--active-trail{% endif %}">
{{- item.title -}}
</a>
{% if has_children %}
<ul class="structural-pages-menu__list structural-pages-menu__list--level-{{ depth + 1 }}">
{% for child in item.children %}
{{ _self.menu_item(child, active_trail, depth + 1) }}
{% endfor %}
</ul>
{% endif %}
</li>
{% endmacro %}