我有一個layout.html頁面<footer>,我想在幾乎所有使用{% extends "layout.html %}. 只有在用戶個人資料頁面中,頁腳才會不同。我怎樣才能做到這一點?
uj5u.com熱心網友回復:
您可以在布局頁面中實作頁腳塊并相應地覆寫它:
{# layout.html #}
...
<div class="container">
...
{% block app_content %}{% endblock %}
{# block exists for all child templates #}
{% block footer %}{% endblock %}
</div>
...
{# profile.html #}
{% extends "layout.html" %}
{# the footer will automatically be placed inside container #}
{# you can override app_content for the body #}
{% block app_content %}...{% endblock %}
{% block footer %}{% include "profile_footer.html" %}{% endblock %}
{# footer.html #}
{# won't be included in profile.html #}
<footer>my footer</footer>
{# profile_footer.html #}
{# will be included in profile.html #}
<footer>profile footer</footer>
對于您不想要頁腳的任何頁面,請忽略該塊
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/339948.html
上一篇:完成功能時找不到臨時檔案
