2014-04-30 25 views
0

我對樹枝有一些麻煩。我不明白爲什麼我的一個塊在我的頁面中呈現兩次。樹枝包括渲染兩個時間塊

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

佈局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> 

我不明白爲什麼認爲側邊欄context.html。樹枝第一次在正確的地方渲染,另一次在包含頁腳-js之前...

感謝

+0

你的頁腳文件是什麼樣的? – mickburkejnr

+0

請提供'footer-js-v2.html.twig'的來源。 –

+0

好吧我明白爲什麼,這是因爲當我顯示塊('內容')時,它會顯示第一次側邊欄,第二次顯示塊右側欄中的佈局。但是,如何在eath用戶佈局和公共佈局中顯示一次沒有重複的代碼? –

回答

1

你可以在A-propos.html.twig上的兩個部分,例如分裂{%嵌段含量%}contetn1之前rightbar and contetn2之後。