From c391caff911e96415a7a2a17bdff23183b00c63d Mon Sep 17 00:00:00 2001 From: "pmoreno.rodriguez" Date: Sat, 28 Oct 2023 22:14:49 +0200 Subject: [PATCH] Redefined macros for navigation and page toc --- templates/components/page-toc.html.twig | 16 ++---------- .../{topmenu.html.twig => macros.html.twig} | 25 ++++++++++++++++--- templates/partials/navigation.html.twig | 4 +-- 3 files changed, 26 insertions(+), 19 deletions(-) rename templates/macros/{topmenu.html.twig => macros.html.twig} (55%) diff --git a/templates/components/page-toc.html.twig b/templates/components/page-toc.html.twig index 33e952c..43109fe 100755 --- a/templates/components/page-toc.html.twig +++ b/templates/components/page-toc.html.twig @@ -1,16 +1,4 @@ -{% macro toc_loop(items) %} - {% for item in items %} - {% set class = loop.first ? 'first' : loop.last ? 'last' : null %} -
  • - {{ item.label }} - {% if item.children|length > 0 %} - - {% endif %} -
  • - {% endfor %} -{% endmacro %} +{% import 'macros/macros.html.twig' as toc_macros %} {% if active or toc_config_var('active') %}
    @@ -18,7 +6,7 @@ {% if table_of_contents is not empty %}

    {{ 'PLUGIN_PAGE_TOC.TABLE_OF_CONTENTS'|t }}

    {% endif %}
    diff --git a/templates/macros/topmenu.html.twig b/templates/macros/macros.html.twig similarity index 55% rename from templates/macros/topmenu.html.twig rename to templates/macros/macros.html.twig index 80319b5..a86f812 100644 --- a/templates/macros/topmenu.html.twig +++ b/templates/macros/macros.html.twig @@ -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 %} +
  • + {{ item.label }} + {% if item.children|length > 0 %} + + {% endif %} +
  • + {% 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 %} {% else %} @@ -27,4 +46,4 @@ {% endif %} {% endfor %} -{% endmacro %} +{% endmacro %} \ No newline at end of file diff --git a/templates/partials/navigation.html.twig b/templates/partials/navigation.html.twig index 2180c41..15e57fd 100755 --- a/templates/partials/navigation.html.twig +++ b/templates/partials/navigation.html.twig @@ -1,7 +1,7 @@ -{% import 'macros/topmenu.html.twig' as macros %} +{% import 'macros/macros.html.twig' as nav_macros %}