{% set tplFixed = constant('AppBundle\\Enum\\TypeTemplateTitle::FIXED') %}
{% set tplList = constant('AppBundle\\Enum\\TypeTemplateTitle::LIST') %}
{% set tplListChild = constant('AppBundle\\Enum\\TypeTemplateTitle::LIST_CHILD') %}
{% set tplNews = constant('AppBundle\\Enum\\TypeTemplateTitle::NEWS') %}
{% set tplPresentation = constant('AppBundle\\Enum\\TypeTemplateTitle::PRESENTATION') %}
{% set tplSimple = constant('AppBundle\\Enum\\TypeTemplateTitle::SIMPLE') %}
{% set tplContact = constant('AppBundle\\Enum\\TypeTemplateTitle::CONTACT') %}
{% set tplPartners = constant('AppBundle\\Enum\\TypeTemplateTitle::PARTNERS') %}
{% set tplTestimonials = constant('AppBundle\\Enum\\TypeTemplateTitle::TESTIMONIALS') %}

{% spaceless %}
    <ul class="footer-menu row">
        {% set m_level1_wo_children = 0 %} {# Nombre de menu de niveau 1 sans sous-menu #}

        {% for m_level1 in menus %}
            {% set m_level1_class = 'col-md-3 entry' %}

            {# Le menu de niveau 1 n'a pas de sous-menu #}
            {% if m_level1.children|length == 0 %}
                {% set m_level1_wo_children = m_level1_wo_children + 1 %}
                {% set m_level1_class = m_level1_class ~ '-single entry-single-' ~ m_level1_wo_children %}
            {% endif %}

            <li class="{{ m_level1_class }} entry-{{ m_level1.slug|replace({'/' : '-'}) }}">
                {% if m_level1.typeTemplate.title in [tplSimple, tplList, tplPresentation, tplListChild, tplContact] %}
                    <a href="{{ path('template', {id:m_level1.id, title:m_level1.slug}) }}">{{ m_level1.title }}</a>
                {% elseif m_level1.typeTemplate.title == tplFixed %}
                    <a href="{{ m_level1.slug }}">{{ m_level1.title }}</a>
                {% elseif m_level1.typeTemplate.title == tplPartners %}
                    <a class="menu-link" href="{{ path('list_partners', {id:m_level1.id, slug:m_level1.slug}) }}" >{{ m_level1.title }}</a>
                {% elseif m_level1.typeTemplate.title == tplTestimonials %}
                    <a class="menu-link" href="{{ path('list_testimonials', {id:m_level1.id, slug:m_level1.slug}) }}" >{{ m_level1.title }}</a>
                {% else %}
                    <span>{{ m_level1.title }}</span>
                {% endif %}

                {% if m_level1.children|length > 0 %}
                <ul>
                    {% for m_level2 in m_level1.children %}
                        <li class="entry-{{ m_level2.slug|replace({'/' : '-'}) }}">
                            {% if m_level2.typeTemplate.title in [tplSimple, tplList, tplPresentation, tplListChild, tplContact] %}
                                <a href="{{ path('template_level2', {id:m_level2.id, title:m_level2.slug, idlevel1:m_level1.id, titlelevel1:m_level1.slug}) }}">{{ m_level2.title }}</a>
                            {% elseif m_level2.typeTemplate.title == tplFixed %}
                                <a href="{{ m_level2.slug }}">{{ m_level2.title }}</a>
                            {% elseif m_level2.typeTemplate.title == tplNews %}
                                <a href="{{ path('list_actu', {id:m_level1.id, slug:m_level1.slug, catid:m_level2.id, catslug: m_level2.slug}) }}">{{ m_level2.title }}</a>
                            {% elseif m_level2.typeTemplate.title == tplPartners %}
                                <a class="menu-link" href="{{ path('list_partners', {id:m_level2.id, slug:m_level2.slug}) }}" >{{ m_level2.title }}</a>
                            {% elseif m_level2.typeTemplate.title == tplTestimonials %}
                                <a class="menu-link" href="{{ path('list_testimonials', {id:m_level2.id, slug:m_level2.slug}) }}" >{{ m_level2.title }}</a>
                            {% else %}
                                {#<span>{{ m_level2.title }}</span>#}
                            {% endif %}

                            {# {% if m_level2.children|length > 0 %}
                            <ul>
                                {% for m_level3 in m_level2.children %}
                                    <li class="entry-{{ m_level3.slug|replace({'/' : '-'}) }}">
                                        {% if m_level3.typeTemplate.title in [tplSimple, tplList, tplPresentation, tplContact, tplTestimonials] %}
                                            <a href="{{ path('template_level3', {id:m_level3.id, title:m_level3.slug, idlevel1:m_level1.id, titlelevel1:m_level1.slug, idlevel2:m_level2.id, titlelevel2:m_level2.slug}) }}">{{ m_level3.title }}</a>
                                        {% elseif m_level3.typeTemplate.title == tplFixed %}
                                            <a href="{{ m_level3.slug }}">{{ m_level3.title }}</a>
                                        {% elseif m_level3.typeTemplate.title == tplPartners %}
                                            <a class="menu-link" href="{{ path('list_partners', {id:m_level3.id, slug:m_level3.slug}) }}" >{{ m_level3.title }}</a>
                                        {% elseif m_level3.typeTemplate.title == tplTestimonials %}
                                            <a class="menu-link" href="{{ path('list_testimonials', {id:m_level3.id, slug:m_level3.slug}) }}" >{{ m_level3.title }}</a>
                                        {% else %} #}
                                            {#<span>{{ m_level3.title }}</span>#}
                                        {# {% endif %}
                                    </li>
                                {% endfor %}
                            </ul>
                            {% endif %} #}
                        </li>
                    {% endfor %}
                </ul>
                {{ render(controller('AppBundle:Render:module', { position:'menu_sitemap_' ~ (m_level1.slug)|replace({'-': '_'}) })) }}
                {% endif %}
            </li>
        {% endfor %}
    </ul>
{% endspaceless %}