Build menu from StaticMenu
0
Required plugin winter.page
[staticMenu mainMenu]
code = "menu_principale"
==
{% import _self as nav %}
{% macro render_menu(items) %}
{% import _self as nav %}
{% for item in items | filter(item => not item.viewBag.isHidden) %}
<li class="{{ item.isActive ? 'current-menu-item' }}
{{ item.isChildActive ? 'current-menu-item' }}
{{ item.viewBag.cssClass }}">
{% if item.url %}
<a href="{{ item.url }}" {{ item.viewBag.isExternal ? 'target="_blank"' }}>
{{ item.code ? item.code|_ : item.title }}
</a>
{% else %}
<a> {{ item.code ? item.code|_ : item.title }} </a>
{% endif %}
{% if item.items %}
<ul class="sub-menu">
{{ nav.render_menu(item.items) }}
</ul>
{% endif %}
</li>
{% endfor %}
{% endmacro %}
and with Twig tag you can make menu :
{% if mainMenu.menuItems %}
<ul>
{{ nav.render_menu(mainMenu.menuItems) }}
</ul>
{% endif %}
There are no comments yet
Be the first one to comment