【TP3.2】模板引用头和尾.html文件

传送门:http://document.thinkphp.cn/manual_3_2.html#include

使用模版表达式

模版表达式的定义规则为:模块@主题/控制器/操作

例如:

<include file="Public/header" /> // 包含头部模版header
<include file="Public/menu" /> // 包含菜单模版menu
<include file="Blue/Public/menu" /> // 包含blue主题下面的menu模版

为了兼容3.1的写法,也可以支持:

<include file="Public:header" />
<include file="Public:menu" />
<include file="Blue:Public:menu" />

可以一次包含多个模版,例如:

<include file="Public/header,Public/menu" />

使用模版文件

可以直接包含一个模版文件名(包含完整路径),例如:

<include file="./Application/Home/View/default/Public/header.html" />

传入参数

无论你使用什么方式包含外部模板,Include标签支持在包含文件的同时传入参数,例如,下面的例子我们在包含header模板的时候传入了title和keywords变量:

<include file="Public/header" title="ThinkPHP框架" keywords="开源WEB开发框架" />

就可以在包含的header.html文件里面使用title和keywords变量,如下:

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>[title]</title>
<meta name="keywords" content="[keywords]" />
</head>
原文地址:https://www.cnblogs.com/xuzhengzong/p/7737944.html