{% extends 'Front/layout.html.twig' %}

{% set metatitle = content.metatitle ? content.metatitle : content.menu %}
{% set metadescription = content.metadescription ? content.metadescription : null %}

{% set bodyClass = content.menu.class %}

{% block body %}
    <div class="row">
        <div class="content list col">
            <div class="content-text">
                {{ content.article|replace_custom_keys|raw }}
            </div>

            <div class="row list-cards cards-news">
                {% for actu in actus %}
                    <div class="col-md-6">
                        <article class="list-item card bg-theme">
                            <div class="item-header">
                                <div class="figure" {% if actu.picture is not empty %}style="background-image: url({{ asset(actu.getWebPath()|imagine_filter('500L'))|replace({' ' : '%20'}) }});"{% endif %}></div>
                            </div>
                            <div class="item-content">
                                <header>
                                    <time class="date" datetime="{{ actu.created|date("Y-m-d") }}">{{ actu.created|date("d/m/Y") }}</time>
                                    <h3 class="item-title h5 text-no-transform">
                                        <a href="{{ path('single_actu', {idlevel1:content.menu.id, titlelevel1:content.menu.slug, idlevel2:actu.menu.id, titlelevel2:actu.menu.slug, id:actu.id, title:actu.title|lower|replace({' ':'-'})|url_encode}) }}">{{ actu.title }}</a>
                                    </h3>
                                </header>
        
                                {# <div class="item-desc">
                                    {{ actu.article|striptags|truncate(300, false, ' ...')|raw }}
                                </div> #}
        
                                <footer class="item-more-actions">
                                    <p><a class="btn btn-xs btn-white" href="{{ path('single_actu', {idlevel1:content.menu.id, titlelevel1:content.menu.slug, idlevel2:actu.menu.id, titlelevel2:actu.menu.slug, id:actu.id, title:actu.title|lower|replace({' ':'-'})|url_encode}) }}">{{ 'word.learn_more'|trans({}, 'word') }}</a></p>
                                </footer>
                            </div>
                        </article>
                    </div>
                {% endfor %}
            </div>

            {% include 'Front/Paginator/pagination.html.twig' with {
                pages:pagination|length
            } only %}
        </div>

        {% include "Front/_part/sidebar.html.twig" %}
    </div>
{% endblock %}

{% block before_body %} 
    {% set pageHeaderPicture = ( content.picture ? asset(content.getWebPath()) : null ) %}
    {% set pageHeaderTitle = content.title %}
    {% set pageHeaderIntroduction = content.introduction|replace_custom_keys|raw %}
    {% include "Front/_part/page-header.html.twig" %}
    {{ render(controller('AppBundle:Render:module', { position:'before_body' })) }}

    {% set sidebar = render(controller('AppBundle:Render:module', { position:'sidebar_right' })) %}
    <div class="container">
        <div class="row">
            <div class="filter-news {% if sidebar %}col-xl-9{% else %}col{% endif %}">
                <form name="filter_form" class="form filter_form form-horizontal" method="post" id="form_filter_news">
                    <div class="form-group row">
                        <label class="col-form-label col-4 col-md-2 offset-md-3 text-right" for="filter_news_by">{{ 'form.filter_by.label'|trans({}, 'form') }}</label>    
                        <div class="col-6 col-md-4">
                            <div class="select-wrapper">
                                <select id="filter_news_by" name="filter_news_by" class="form-control with-border filter_by">
                                    {{
                                        include('Front/_component/filter-item.html.twig', {
                                            href: absolute_url(path('list_actu', {id:content.menu.id, slug:content.menu.slug, catid:0, catslug:'All'})),
                                            id: content.menu.id,
                                            selected: 'All' == selected_catslug ? true : false,
                                            title: 'Toutes'
                                        })
                                    }}
                                    {% for child in content.menu.children %}
                                        {% if child.isActive %}
                                            {{
                                                include('Front/_component/filter-item.html.twig', {
                                                    href: absolute_url(path('list_actu', {id:content.menu.id, slug:content.menu.slug, catid:child.id, catslug: child.slug })),
                                                    id: child.id,
                                                    selected: child.id == selected_catid ? true : false,
                                                    title: child.title
                                                })
                                            }}
                                        {% endif %}
                                    {% endfor %}
                                </select>
                            </div>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
{% endblock %}

{% block after_body %} 
    {{ render(controller('AppBundle:Render:module', { position:'after_body' })) }}
{% endblock %}