ThinkPHP 3.1.2 模板的使用技巧
2016-04-21 15:23
525 查看
本节课大纲: 一、模板包含 <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 模板的使用技巧
- ThinkPHP 3.1.2 模板的使用技巧
- 使用PHP QRcode生成二维码广告图
- php 导出数据到excel(缓冲区应用)
- php打印xml格式数据
- 切到 PHP7,我们是如何节省一百万美元的?
- ThinkPHP缓存微信公众号access_token
- PHP SOAP实现WebService
- ThinkPHP多表操作
- 如何在FTP服务器上传和下载文件
- 关于php中json_encode中文乱码问题
- php分享(三十六)mysql中关联表更新
- PHP间隔一段时间执行
- PHP 自定义方法实现数组合并
- ThinkPHP使用SQL函数进行查询
- laravel各种路径的获取方法
- LTP工具说明
- ios下使用rsa算法与php进行加解密通讯
- phpcms开发使用
- TP3.2整合kindeditor