Files
structural_pages/templates/structural-pages-menu.html.twig
Quintino A. G. Souza 36c3a2e9c0 Altera lógica de Site Section e adiciona redirect em content_page
- Adiciona campo field_redirect_link (link) no bundle content_page;
  EventSubscriber emite redirect 301 quando o campo está preenchido
- field_site_section passa a ser obrigatório
- Formulário de content_page: AJAX no site section, select hierárquico
  de página pai filtrado por seção, validação customizada
- StructuralPagesMenuBlock: MAX_DEPTH 10→50, nova lógica de raiz via
  field_site_section, variável ancestor_url no render array
- Template do menu: novas classes BEM/Gva, suporte a is_redirect,
  usa ancestor_url em vez de chamada Twig direta
- CSS do menu reescrito com estilos flyout/sidebar; Select2 adicionado
  para o campo de página pai no formulário admin
- display_submitted desabilitado no tipo content_page

Co-Authored-By: Bauer <henrique@webcontent.com.br>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-03 08:04:43 -03:00

69 lines
2.3 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="block-menu navigation structural-pages-menu" aria-label="{{ 'Site structure navigation'|t }}">
{% if show_ancestor_title and ancestor %}
<h2 class="structural-pages-menu__title block-title">
<span>
{% if ancestor_url %}
<a href="{{ ancestor_url }}">{{ ancestor.label }}</a>
{% else %}
{{ ancestor.label }}
{% endif %}
</span>
</h2>
{% endif %}
<div class="block-content">
<ul class="gva_menu structural-pages-menu__list structural-pages-menu__list--level-1">
{% for item in tree %}
{{ _self.menu_item(item, active_trail, 1) }}
{% endfor %}
</ul>
</div>
</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 = [
'menu-item',
'structural-pages-menu__item',
'structural-pages-menu__item--level-' ~ depth,
is_active ? 'menu-item--active-trail structural-pages-menu__item--active-trail',
has_children ? 'menu-item--expanded structural-pages-menu__item--has-children',
] %}
<li{{ create_attribute().addClass(classes) }}>
<a href="{{ item.url }}"{% if item.is_redirect %} target="_blank"{% endif %} class="structural-pages-menu__link{% if is_active %} is-active structural-pages-menu__link--active-trail{% endif %}">
{{- item.title -}}
</a>
{% if has_children %}
<ul class="menu sub-menu 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 %}