本节课大纲: 一、模板包含 <include file="完整模板文件名" /> <include file="./Tpl/default/Public/header.html" /> <include file="read" /> <include file="Public:header" /> <include file="blue:User:read" /> <include file="$tplName" /> <include file="header" title="ThinkPHP框架"keywords="开源WEB开发框架"/> 在模板中变量用[变量]接受 <include file='file1,file2' /> 二、模板渲染 1、自动开启模板渲染 设置配置文件 'LAYOUT_ON'=>true,//开启模板渲染 准备一个模板渲染页面,在页面中使用{__CONTENT__}接受具体模板页面的内容 如果在摸一个具体模板中不希望使用渲染模板,可以在页首添加{__NOCONTENT__} 2、不开启自动模板渲染可以在每一个具体页面的页首添加 <layout name='layout'/> 三、模板的继承 // <p>这里是首页</p> <a href='__URL__/next'>跳转到下一页</a> 点击超链接,去查找next方法 非法操作:next 错误位置 FILE: C:\wamp\www\thinkphp2\ThinkPHP\Lib\Core\Action.class.php LINE: 231 在框架之中,找一个具体页面的时候,总是跳转到一个方法,总是有控制器里的方法,为我们输出页面 <!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="Generator" content="EditPlus®"> <meta name="Author" content=""> <meta name="Keywords" content=""> <meta name="Description" content=""> <!--<link rel='stylesheet' type='text/css' href='__PUBLIC__/Css/test.css'/>--> <!--<script src='__PUBLIC__/Js/test.js'></script>--> <!--<import type='css' File='Css.test'/> <import type='js' File='Js.test'/>--> <title>Document</title> </head> <body> <p>这里是首页</p> <a href='__URL__/next'>跳转到下一页</a> </body> </html> 超连接查找next 方法 public function next(){ $this->display(); } netx 方法对应的页面 //thinkphp 公共的模板文件 $ pwd /cygdrive/c/wamp/www/thinkphp2/Home/Tpl/Public Administrator@QCEE61NZ66FEX2D /cygdrive/c/wamp/www/thinkphp2/Home/Tpl/Public $ ls head.html header.html <html lang="en"> <head> <meta charset="UTF-8"> <meta name="Generator" content="EditPlus?"> <meta name="Author" content=""> <meta name="Keywords" content=""> <meta name="Description" content=""> <title>Document</title> <load file="__PUBLIC__/Css/test.css"/> </head> </html> 引入header.html模板文件 <!doctype html> <include file="Public:header"/> <body> <p>这里是首页</p> <p>"__APP__/Public/code"<p> <a href='__URL__/next'>跳转到下一页</a> </body> </html>
ThinkPHP 3.1.2 模板的使用技巧
转载本文章为转载内容,我们尊重原作者对文章享有的著作权。如有内容错误或侵权问题,欢迎原作者联系我们进行内容更正或删除文章。
上一篇:Mongodb创建用户
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
thinkPHP 模板的使用技巧(十三)
thinkPHP 模板的使用技巧(十三)
thinkPHP 模板的使用技巧十三 html Public 页面跳转 -
Thinkphp 模板函数的使用
thinkphp 视图函数
php 默认值 数组 字符串