{% extends 'Front/layout.html.twig' %}
{% set metatitle = content.metatitle ? content.metatitle : content.menu ~ ' - Cgénial' %}
{% set metadescription = content.metadescription ? content.metadescription : null %}

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

            <div class="listMedia row list-cards cards-medias">
                {% for video in videos %}
                    <div class="col-md-6 col-lg-4">
                        <article class="card bg-theme">
                            <div class="item-content">
                                {{
                                    include('Front/_component/video.html.twig', {
                                        id: video.path,
                                    })
                                }}
                                <footer class="topVideo">
                                    <time class="date" datetime="{{ video.created|date('Y-m-d') }}">{{ video.created|date("d/m/Y") }}</time>
                                    <h3 class="item-title h5 text-no-transform">{{ video.title }}</h3>
                                </footer>
                            </div>
                        </article>
                    </div>
                {% endfor %}
            </div>
            {% include 'Front/Paginator/pagination.html.twig' with {
                pages:pagination|length
            } only %}
        </section>

        {% 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-medias {% if sidebar %}col-xl-9{% else %}col{% endif %}">
                <form name="filter_form" class="form filter_form form-horizontal" method="post" id="form_filter_medias">
                    <div class="form-group row">
                        <label class="col-form-label col-4 col-md-2 offset-md-3 text-right" for="filter_medias_by">{{ 'form.filter_by.label'|trans({}, 'form') }}</label>
                        <div class="col-6 col-md-4">   
                            <div class="select-wrapper">
                                <select id="filter_medias_by" name="filter_medias_by" class="form-control with-border filter_by">
                                    {{
                                        include('Front/_component/filter-item.html.twig', {
                                            href: absolute_url(path('list_media', {id:content.menu.id, slug:content.menu.slug, catid:0, catslug:'All'})),
                                            id: content.menu.id,
                                            selected: 'All' == selected_catslug ? true : false,
                                            title: content.title
                                        })
                                    }}
                                    {% for child in content.menu.children %}
                                        {% if child.isActive %}
                                            {{
                                                include('Front/_component/filter-item.html.twig', {
                                                    href: absolute_url(path('list_media', {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 %}