Redefined macros for navigation and page toc

This commit is contained in:
pmoreno.rodriguez 2023-10-28 22:14:49 +02:00
parent 3a2466e787
commit c391caff91
3 changed files with 26 additions and 19 deletions

View file

@ -1,16 +1,4 @@
{% macro toc_loop(items) %}
{% for item in items %}
{% set class = loop.first ? 'first' : loop.last ? 'last' : null %}
<li {% if class %}class="{{ class }}"{% endif %}>
<a href="{{ item.uri }}">{{ item.label }}</a>
{% if item.children|length > 0 %}
<ul>
{{ _self.toc_loop(item.children) }}
</ul>
{% endif %}
</li>
{% endfor %}
{% endmacro %}
{% import 'macros/macros.html.twig' as toc_macros %}
{% if active or toc_config_var('active') %}
<div class="page-toc">
@ -18,7 +6,7 @@
{% if table_of_contents is not empty %}
<h3>{{ 'PLUGIN_PAGE_TOC.TABLE_OF_CONTENTS'|t }}</h3>
<ul>
{{ _self.toc_loop(table_of_contents.children) }}
{{ toc_macros.toc_loop(table_of_contents.children) }}
</ul>
{% endif %}
</div>

View file

@ -1,5 +1,24 @@
{# MACRO FOR PAGE-TOC PLUGIN SUPPORT #}
{% macro toc_loop(items) %}
{% import _self as toc_macros %}
{% for item in items %}
{% set class = loop.first ? 'first' : loop.last ? 'last' : null %}
<li {% if class %}class="{{ class }}"{% endif %}>
<a href="{{ item.uri }}">{{ item.label }}</a>
{% if item.children|length > 0 %}
<ul>
{{ toc_macros.toc_loop(item.children) }}
</ul>
{% endif %}
</li>
{% endfor %}
{% endmacro %}
{# MACRO FOR TOP MENU NAVIGATION #}
{% macro nav_loop(page) %}
{% import _self as macros %}
{% import _self as nav_macros %}
{% for p in page.children.visible %}
{% set current_page = (p.active or p.activeChild) ? 'active' : '' %}
{% if p.children.visible.count > 0 %}
@ -13,7 +32,7 @@
{% endif %}
</a>
<ul>
{{ macros.nav_loop(p) }}
{{ nav_macros.nav_loop(p) }}
</ul>
</li>
{% else %}

View file

@ -1,7 +1,7 @@
{% import 'macros/topmenu.html.twig' as macros %}
{% import 'macros/macros.html.twig' as nav_macros %}
<ul>
{{ macros.nav_loop(pages) }}
{{ nav_macros.nav_loop(pages) }}
{% if theme_var('custommenus.enabled') %}
{% for mitem in theme_var('custommenu') %}