<!-- SIDE MENU : begin -->
{% set url = craft.app.request.getHostInfo() ~ craft.app.request.url %}
{% set active = false %}
{% if header.menu.all()|length %}
<nav class="{{ class }}">
    <ul>
        {% for menuItem in header.menu.all() %}
            {% switch menuItem.type %}
                {% case 'children' %}
                    {% for item in menuItem.submenu.all() %}
                        {% if url == item.url %}
                            {% set active = true %}
                        {% endif %}
                    {% endfor %}
                    {% set linkPrincipal = menuItem.linkPrincipal.one() %}
                    {% if linkPrincipal|length %}
                        <li class="{{ active or linkPrincipal.url == url ? 'm-active' }}">
                            <a href="{{ linkPrincipal.url }}">{{ menuItem.label }}</a>
                    {% else%}
                        <li class="{{ active ? 'm-active' }}">
                        <a href="#">{{ menuItem.label }}</a>
                    {% endif%}

                        <ul>
                            {% for item in menuItem.submenu.all() %}
                                <li class="{{ item.url == url ? 'm-active' }}"><a href="{{ item.url }}">{{ item.title }}</a></li>
                            {% endfor %}
                        </ul>
                    </li>
                    {% set active = false %}
                {% case 'single' %}
                {% set linkPrincipal = menuItem.linkPrincipal.one() %}
                {% if linkPrincipal|length %}
                <li class="{{ active or linkPrincipal.url == url ? 'm-active' }}">
                    <a href="{{ linkPrincipal.url }}">{{ menuItem.label }}</a>
                    {% else%}
                <li class="{{ active ? 'm-active' }}">
                    <a href="#">{{ menuItem.label }}</a>
                    {% endif%}
                </li>
                {% case 'subchildren' %}
                {% include '_layout/_components/_blocks/subChildrenTwo.twig' with {
                    menuItem: menuItem
                } %}
            {% endswitch %}

        {% endfor %}
    </ul>
</nav>
{% endif %}
<!-- SIDE MENU : end -->