{% if eventsList %}
    {% set AgendaRoot = load_content_by_location_id(rootID) %}

    <div class="agenda-2-wrap">
        <div class="agenda-2">
            <div class="agenda-2-in" id="mea-agenda">
                <div class="inner-agenda">
                    <div class="in-agenda swiper-container swiper-container-horizontal">
                        <div class="inner-inner-agenda swiper-wrapper">
                            {% for event in eventsList %}
                                <article class="swiper-slide">
                                    <a href="{{ path('ez_urlalias', {'locationId': event.contentInfo.mainLocationId }) }}"
                                       title="{{ ez_field_value(event, 'titre')|escape }}">
                                        {% if event.getFieldValue( 'vignette' ).destinationContentId is defined and event.getFieldValue( 'vignette' ).destinationContentId %}
                                            {% set imageContent = load_content_by_content_id(event.getFieldValue('vignette').destinationContentId) %}
                                            {{ ez_render_field( imageContent, "image", {'parameters': { 'alias': 'event_home_mini_site'} } ) }}
                                        {% endif %}
                                        <div class="event-caption">
                                            <div class="bloc-date">
                                                {% if event.fields.date_debut is defined and not ez_is_field_empty( event, "date_debut" ) %}
                                                    <div>
                                                        <strong class="date">
                                                            <span class="day">{{ ez_field_value(event, "date_debut")|localizeddate('none', 'none', app.request.locale, null, "dd") }}</span>
                                                            <span class="month">{{ ez_field_value(event, "date_debut")|localizeddate('none', 'none', app.request.locale, null, "MMM") }}</span>
                                                        </strong>
                                                    </div>
                                                {% endif %}
                                                {% if event.fields.date_debut is defined and not ez_is_field_empty( event, "date_debut" ) and event.fields.date_fin is defined and not ez_is_field_empty( event, "date_fin" ) and event.getFieldValue('date_debut').date != event.getFieldValue('date_fin').date %}
                                                    <div>
                                                        <strong class="date">
                                                            <span class="day">{{ ez_field_value(event, "date_fin")|localizeddate('none', 'none', app.request.locale, null, "dd") }}</span>
                                                            <span class="month">{{ ez_field_value(event, "date_fin")|localizeddate('none', 'none', app.request.locale, null, "MMM") }}</span>
                                                        </strong>
                                                    </div>
                                                {% endif %}
                                            </div>
                                            <div class="inner-article">
                                                <div class="description-event">
                                                    <div class="sous_titre_event">{{ ez_render_field(event, 'thematiques') }}</div>
                                                    <h3 class="event_name">{{ ez_render_field(event, 'titre')|raw }}</h3>
                                                    {#{% if AgendaRoot and AgendaRoot.fields['mode_escale'] is defined and not ez_is_field_empty(AgendaRoot, 'mode_escale') %}#}
                                                    {% if (event.fields.horaire is defined and not ez_is_field_empty(event, 'horaire') or (event.fields.abonnement is defined and not ez_is_field_empty(event, 'abonnement'))) %}
                                                        <ul class="event-infos">
                                                            {% if event.fields.horaire is defined and not ez_is_field_empty(event, 'horaire')  %}
                                                                <li class="time-info">
                                                                    <span class="icon-time"></span>
                                                                    <span class="title-time">{{ ez_render_field(event, 'horaire') }}</span>
                                                                </li>
                                                            {% endif %}
                                                            {% if event.fields.abonnement is defined and not ez_is_field_empty(event, 'abonnement') %}
                                                                <li class="tarif-info">
                                                                    <span class="icon-abonnement"></span>
                                                                    <span class="title-tarif">Tarif réduit</span>
                                                                </li>
                                                            {% endif %}
                                                        </ul>
                                                    {% endif %}

                                                </div>
                                            </div>
                                        </div>
                                    </a>
                                </article>
                            {% endfor %}
                        </div>
                        <div class="swiper-scrollbar"></div>
                    </div>
                    {{ render_esi (controller("AyalineCollectiviteBundle:Home:getBlocHome", {"type": 'acces_thematique_agenda_racine', "template" : "AyalineEzMiniSitesCollectivitesBundle:parts:acces_thematique_agenda.html.twig" } )) }}

                </div>
                {% block lien_agenda %}
                    {% if rootID %}
                        <div class="voir-tout-wrapper">
                            <a href="{{ path( 'ez_urlalias', {'locationId': rootID } ) }}" class="voir-plus">Toute la programmation</a>
                        </div>
                    {% endif %}
                {% endblock %}
            </div>

        </div>
    </div>
{% endif %}