首页
新建首頁模板 static/view/index.twig
TIP
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>Home Page</title>
</head>
<body>
<header>这里是页眉</header>
<main>这里是主体</main>
<footer>这里是页脚</footer>
</body>
</html>
查看 https://localhost/DaCoreExample/

TIP
流程简述:
通常一个网站除主体部分,其它是可以共用的。所以可以把main外的其它部分提出来.
新建 layout.twig,复制 index.twig 内容并把<main></main>改成twig的block
static/view/layout.twig
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>Home Page</title>
</head>
<body>
<header>这里是页眉</header>
{% block main %}这里是主体部分{% endblock %}
<footer>这里是页脚</footer>
</body>
</html>
修改 index.twig 继承 layout.twig
static/view/index.twig
{% extends 'layout.twig' %}
{% block main %}
<main>
这里是主体,使用布局后
</main>
{% endblock %}
再次查看 https://localhost/DaCoreExample/
