{% macro menu(menu, anchorlink, cssClass, currentModule, currentAction, collapsible, isSuperUser) %}
    <div id="secondNavBar" class="{{ cssClass }} z-depth-1">
        <ul class="navbar {% if collapsible %}collapsible collapsible-accordion{% endif %} hide-on-med-and-down" aria-label="{{ 'CoreHome_MainNavigation'|translate|e('html_attr') }}" role="menu">
            {% for level1,level2 in menu %}

                {% set hasSubmenuItem = false %}
                {% set hasActive = false %}
                {% for name,urlParameters in level2 %}
                    {% if name|slice(0,1) != '_' %}
                        {% set hasSubmenuItem = true %}
                    {% endif %}
                {% endfor %}

                {% if hasSubmenuItem %}
                    {% set subMenu %}
                        <a class="item {% if collapsible %}collapsible-header{% endif %}" tabindex="5">
                            <span class="menu-icon {{ level2._icon|default('icon-chevron-down') }}"></span>{{ level1|translate }}
                            <span class="hidden">
                             {{ 'CoreHome_Menu'|translate }}
                           </span>
                        </a>
                        <ul role="menu" {% if collapsible %}class="collapsible-body"{% endif %}>
                            {% for name,urlParameters in level2 %}
                                {% if name|slice(0,1) != '_' %}
                                    {% set isActive = urlParameters._url.module is defined and urlParameters._url.module == currentModule and urlParameters._url.action is defined and urlParameters._url.action == currentAction %}
                                    {% set hasActive = hasActive or isActive %}
                                    <li {% if isActive %}class="active"{% endif %}
                                        role="menuitem"
                                    >
                                        <a class="item{% if urlParameters._cssClass %} {{ urlParameters._cssClass|e('html_attr') }}{% endif %}" tabindex="5" target="_self"
                                           title="{{ urlParameters._tooltip|default('')|translate|e('html_attr') }}"
                                            {% if urlParameters._onclick is defined and urlParameters._onclick %}
                                                onclick="{{ urlParameters._onclick|e('html_attr') }};return false;"
                                            {% endif %}
                                            {% if urlParameters._url %}
                                                href="index.php?{{ urlParameters._url|urlRewriteWithParameters|slice(1) }}"
                                            {% endif %}>
                                            {% if urlParameters._icon is defined and urlParameters._icon %}<span class="icon {{ urlParameters._icon|e('html_attr') }}" style="margin-right: 5px;"></span>{% endif %}
                                            {{ name|translate|rawSafeDecoded }}
                                        </a>
                                        {% if urlParameters._help %}
                                            <div vue-entry="CoreHome.ShowHelpLink" name="{{ urlParameters._name }}" message="{{ urlParameters._help|e('html_attr') }}"></div>
                                        {% endif %}
                                    </li>
                                {% endif %}
                            {% endfor %}
                        </ul>
                    {% endset %}
                    <li class="menuTab {% if hasActive %}active{% endif %}" role="menuitem">
                        {{ subMenu }}
                    </li>
                {% endif %}
            {% endfor %}
        </ul>
        <div vue-entry="CoreHome.MobileLeftMenu" menu="{{ menu|json_encode }}"></div>
        {% if isSuperUser %}
            <div vue-entry="CorePluginsAdmin.PluginsUpdateCount" selector=".item.manage-plugins" class="hidden"></div>
        {%  endif %}
    </div>
{% endmacro %}
