I have a layout.html
page with a <footer>
that I want to display in almost all pages using {% extends "layout.html %}
. Only in the user profile page the footer will be different. How can I do that?
CodePudding user response:
You can implement a footer block in the layout page and override it accordinly:
...
<div class="container">
{% block app_content %}{% endblock %}
{# display footer on all pages #}
{% block footer %}{% endblock %}
</div>
...
{# profile.html #}
{% extends "layout.html" %}
{# the footer will automatically be placed inside container and #}
{# you can override app_content #}
{% block app_content %}...{% endblock %}
{% block footer %}{% include "profile_footer.html" %}{% endblock %}
{# footer.html #}
<footer>my footer</footer>
{# profile_footer.html #}
<footer>profile footer</footer>
For any page that you do not want a footer just leave out the block