我想在每页都显示导航栏。在PHP中,我会编写导航栏,然后将其包含在其他页面上。我试图将导航条模板包含或扩展到其他模板中,但没有成功。它只输出“这是主页”,如何正确地将导航栏包含在每个模板中?
layout.html
{% block navbar %}
body {
margin: 0;
padding: 0;
}
div{
background: #333;
color: #f9f9f9;
width: 100%;
height: 50px;
line-height: 50px;
text-align: center;
}
NAVBAR
{% endblock %}
{% block content %}
{% endblock %}
index.htmlThis is the home page.
{% extends "layout.html" %}
{% block navbar %} {% endblock %}
{% block content %}
This is the homepage!
{% endblock %}