From 5c4324e14c6cf4cc7657cdee05ef8e8d3e559dd8 Mon Sep 17 00:00:00 2001 From: "pmoreno.rodriguez" Date: Sun, 26 Nov 2023 10:51:40 +0100 Subject: [PATCH] Macros redefined for navigation --- templates/macros/macros.html.twig | 39 ++++++-------- .../partials/sidebar_navigation.html.twig | 54 ++++++------------- 2 files changed, 30 insertions(+), 63 deletions(-) diff --git a/templates/macros/macros.html.twig b/templates/macros/macros.html.twig index a86f812..f34a9f5 100644 --- a/templates/macros/macros.html.twig +++ b/templates/macros/macros.html.twig @@ -20,30 +20,21 @@ {% macro nav_loop(page) %} {% 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 %} -
  • - - {% if p.header.icon %} + {% set active_page = (p.active or p.activeChild) ? 'active' : '' %} + {% set has_visible_children = p.children.visible.count > 0 %} +
  • + + {% if p.header.icon %} - {% endif %} - {{ p.menu }} - {% if p.routable ?? false %}  - {% endif %} - - -
  • - {% else %} -
  • - - {% if p.header.icon %} - - {% endif %} - {{ p.menu }} - -
  • - {% endif %} + {% endif %} + {{ p.menu }} + {% if has_visible_children %} {% endif %} + + {% if has_visible_children %} + + {% endif %} + {% endfor %} {% endmacro %} \ No newline at end of file diff --git a/templates/partials/sidebar_navigation.html.twig b/templates/partials/sidebar_navigation.html.twig index 0a3fb7a..de48c68 100644 --- a/templates/partials/sidebar_navigation.html.twig +++ b/templates/partials/sidebar_navigation.html.twig @@ -1,34 +1,22 @@ {% block menu_navigation %} - {% macro loop(page) %} - {% for p in page.children.visible %} - {% set current_page = (p.active or p.activeChild) ? 'active' : '' %} - {% if p.children.visible.count > 0 %} -
  • - +{% macro loop(page) %} +{% for p in page.children.visible %} + {% set current_page = (p.active or p.activeChild) ? 'active' : '' %} +
  • + {% if p.header.icon %} - - {% endif %} - {{ p.menu }} - {% if p.routable ?? false %}  - {% endif %} - - - -
  • - {% else %} -
  • - - {% if p.header.icon %} - + {% endif %} {{ p.menu }} - -
  • - {% endif %} - {% endfor %} - {% endmacro %} + + {% if p.children.visible.count > 0 %} + + {% endif %} + +{% endfor %} +{% endmacro %} -{% endblock %} - -{% block javascripts %} - {% endblock %} \ No newline at end of file