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

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

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

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

            <div class="row list-cards cards-content">
                {% for child in children %}
                    {% set content = child.content|first %}
                    {% set link = menu.parent ? path('template_level3', {idlevel1:menu.parent.id, titlelevel1:menu.parent.slug, idlevel2:menu.id, titlelevel2:menu.slug, id:content.menu.id, title:content.menu.slug}) : path('template_level2', {idlevel1:menu.id, titlelevel1:menu.slug, id:content.menu.id, title:content.menu.slug})  %}
                    <div class="col-md-6">
                        <article class="list-item card bg-theme">
                            <div class="item-header">
                                <div class="figure" {% if content.picture is not empty %}style="background-image: url({{ asset(content.getWebPath()|imagine_filter('500L'))|replace({' ' : '%20'}) }});"{% endif %}></div>
                            </div>
                            <div class="item-content">
                                <header>
                                    <h3>
                                        <a href="{{ link }}">{{ content.title }}</a>
                                    </h3>
                                </header>
        
                                {# <div class="item-desc">
                                    {{ content.article|striptags|truncate(300, false, ' ...')|raw }}
                                </div> #}
        
                                <footer class="item-more-actions">
                                    <p><a class="btn btn-xs btn-white" href="{{ link }}">{{ 'word.learn_more'|trans({}, 'word') }}</a></p>
                                </footer>
                            </div>
                        </article>
                    </div>
                {% endfor %}
            </div>
        </div>

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

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

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