Skip to content
Grav 2.0 is officially stable. Read the announcement →
General

UL tag extra in navigation menu

Started by Pedro M 6 years ago · 0 replies · 557 views
6 years ago

Hi.

I have this code in the navigation.html.twig:

TWIG
{% macro nav_loop(page) %}
{% import _self as macros %}

  {% for p in page.children.visible %}
    {% set active_page = (p.active or p.activeChild) ? 'active' : '' %}
    <li class="scroll {{active_page}}"><a href="{{ p.url }}">{{ p.menu }}</a></li>
  {% endfor %}

{% endmacro %}

If you can see the result with the Chrome Inspector, you can check that the code has changed to (for example):

HTML
<ul class="navigation">
<li><a class="" href="#services">services</a></li>
<li><a class="" href="#about-us">about-us</a></li>
</ul>

First: my classes in li tag have dissapeared (scroll, active).
Second: Grav adds and extra ul tag.

All of this makes that I can' take control of my classes, for example, in one theme that contain a line with \<ul class="nav navbar-nav navbar-right"> and then differents lines with \<li class="whatever">, the end result will be:

HTML
<ul class="nav navbar-nav navbar-right">
<ul class="navigation">
<li>whatever</li>
<li>whatever</li>
</ul>
</ul>

Is there any way to make a navigation.html.twig file that respects the css classes?

Thanks in advance.

Suggested topics

Topic Participants Replies Views Activity
General · by jean-louis67, 3 weeks ago
2 308 3 weeks ago
General · by Andy Miller, 3 weeks ago
0 311 3 weeks ago
General · by Veehem, 4 weeks ago
0 263 4 weeks ago
General · by milkboy, 4 weeks ago
0 265 4 weeks ago
General · by ian russell, 1 month ago
2 335 1 month ago