I want to make the main menu of the site, but in such a way that there is a logo in the center and menu items on the left and right.
My idea is this:
ul --- logo --- ul
So I need to divide the menu into two parts.
{% set half_first = pages.children.visible | slice (0, pages.children.visible | length / 2)%}
{% set half_second = pages.children.visible | slice (pages.children.visible | length / 2)%}
{% for p in half_first %}
{{ macros.loop(p) }}
{% endfor %}
File macros.html.twig
{% macro loop(page, parent) %}
{% for p in page.children.visible %}
<li class="nav-item {% if p.children.visible.count > 0 %}dropdown{% endif %}">
{% if p.children.visible.count > 0 %}
<a class="nav-link dropdown-toggle" href="#" data-bs-toggle="dropdown">
{{ p.menu }}
</a>
{% else %}
<a class="nav-link" href="{{ p.url }}">
{{ p.menu }}
</a>
{% endif %}
{% if p.children.visible.count > 0 %}
<ul class="dropdown-menu">
{{ _self.loop(p) }}
</ul>
{% endif %}
</li>
{% endfor %}
{% endmacro %}
Unfortunately it doesn't work :( Any idea?