<section class="col-md-8 dates-retenir">
    <h2 class="h2-home-theme">{{ rootTitle|raw }}</h2>
    <a class="voir-plus" href="{{ path('ez_urlalias', {'locationId': rootID }) }}">Voir tous les événements</a>

    {% if eventsList|length %}
    <div id="slideDates" class="flexslider">
        <div class="flex-viewport">
            <ul class="slides">
                {% for locationId,event in eventsList %}
                    <li class="fitted">
                        <a href="{{ path('ez_urlalias', {'locationId': locationId }) }}"></a>
                        {{ ez_render_field( event, "vignette", { 'template': 'AyalineEzAgendaCollectivitesBundle:fields:event_ezobjectrelation.html.twig', 'parameters': { 'alias': 'home_event_agenda' } } ) }}

                        <div class="caption">
                            <h3>
                                {{ ez_render_field(event, 'thematiques') }}
                            </h3>

                            {% 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 %}

                                <span class="date">Du</span>
                            {% endif %}

                            {% if event.fields.date_debut is defined and not ez_is_field_empty( event, "date_debut" ) %}
                                {% if 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 %}
                                    <span class="date">Le</span>
                                {% endif %}
                                <time datetime="{{ ez_field_value(event, "date_debut")|localizeddate('none', 'none', app.request.locale, null, "yyyy-MM-dd") }}">{{ ez_field_value(event, "date_debut")|localizeddate('none', 'none', app.request.locale, null, "dd MMM") }}</time>

                                {% if 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 %}

                                    <span class="date">Au</span>
                                    <time datetime="{{ ez_field_value(event, "date_fin")|localizeddate('none', 'none', app.request.locale, null, "yyyy-MM-dd") }}">{{ ez_field_value(event, "date_fin")|localizeddate('none', 'none', app.request.locale, null, "dd MMM") }}</time>

                                {% endif %}
                            {% endif %}

                            <p>{{ ez_render_field(event, 'titre') }}</p>
                        </div>


                    </li>
                {% endfor %}
            </ul>
        </div>
        <ul class="flex-direction-nav">
            <li><a class="flex-prev" href="#" tabindex="-1"></a></li>
            <li><a class="flex-next flex-disabled" href="#" tabindex="-1"></a></li>
        </ul>
        {% endif %}
    </div>

</section>
