質問

I've some trouble with Twig. I don't understand why one of my block is rendering two time in my page.

A-propos.html.twig

{% extends "::layout-v2.html.twig" %}

{% set contexte = "a-propos" %}
{% block content %}
//some stuff
 {% block rightbar %}
            {{"Je suis dans le block de la vue rightbar"}}
            {{ parent() }}
 {% endblock %}
//some stuff
{% endblock %}

layout-v2.html.twig

{% include '::header/header-v2.html.twig' %}

<body class="">
{% block topBar %}
{% endblock %}

{% if app.user %}
    {% include '::layout-user-v2.html.twig' with {'view_content': block('content')} %}
{% else %}
    {% include '::layout-public-v2.html.twig' with {'view_content': block('content')} %}
{% endif %}


{% block rightbar %}
<div class="col-sm-3">
    {% if contexte is defined %}
            {% include 'BtpGeneralBundle:Sidebars:sidebar_contexte.html.twig' %}
        {% else %}
            {% include 'BtpGeneralBundle:Sidebars:sidebar_default.html.twig' %}
    {% endif %}
</div>
{% endblock %}

{% include '::footer/footer-js-v2.html.twig' %}

</body>

I don't understand why the view sidebar-context.html.twig is rendering first time on the right place and another time just before the include footer-js...

Thank

役に立ちましたか?

解決

You could split {% block content %} in A-propos.html.twig on two parts, e.g. contetn1 before rightbar and contetn2 after.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top