Hello,
I started using GRAV some days ago and I am still not very familiarized with TWIG Templating. I am using the theme FUTURE2021 and the thing that I am not able to solve by myself is the following:
In my navbar, I want to have some categories listed with a dropdown menu each. BUT, I also want the category title to be clickable. What happens with this theme is that if assign a dropdown menu to the category, the category title becomes unclickable.
I went to check the template TWIG files of the navbar (user/themes/future2021/templates/partials/navigation.html.twig) with the aim of trying to solve it but I was unsuccessful. The below is the code in the above mentioned directory:
**{% import 'macros/macros.html.twig' as nav_macros %}**
<ul>
{{ nav_macros.nav_loop(pages) }}
{% if theme_var('custommenus.enabled') %}
{% for mitem in theme_var('custommenu') %}
<li>
<a href="{{ mitem.url }}" target="{{ mitem.target }}">
{% if mitem.icon %}
<i class="fa fa-{{ mitem.icon }}"></i>
{% endif %}
{{ mitem.text|raw }}
</a>
</li>
{% endfor %}
{% endif %}
</ul>
Highlighted what I did not understand: so the code for the navbar is imported from the macros file? Where should I then focus on changing the code? (which I am still far from understanding fully but at least it would be a start...)
In the macro, the part of the navbar code is as follows:
{# MACRO FOR TOP MENU NAVIGATION #}
{% 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 %}
<li class="{{ current_page }}">
<a>
{% if p.header.icon %}
<i class="fa fa-{{ p.header.icon }}"></i>
{% endif %}
{{ p.menu }}
{% if p.routable ?? false %} <i class="fa fa-angle-down"></i>
{% endif %}
</a>
<ul>
{{ nav_macros.nav_loop(p) }}
</ul>
</li>
{% else %}
<li class="{{ current_page }}">
<a href="{{ p.url }}">
{% if p.header.icon %}
<i class="fa fa-{{ p.header.icon }}"></i>
{% endif %}
<span>{{ p.menu }}</span>
</a>
</li>
{% endif %}
{% endfor %}
{% endmacro %}
Maybe this is too much of a rookie question and I want to make too much personalization for what my current abilities with TWIG are... Anyway, thanks in advance to anyone who might be able to help here.
Cheers :)