ThinkPHP 3.1.2 模板的使用技巧

来源:互联网 发布:昆山仕德伟网络 编辑:程序博客网 时间:2024/06/04 22:35
本节课大纲:一、模板包含<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/PublicAdministrator@QCEE61NZ66FEX2D /cygdrive/c/wamp/www/thinkphp2/Home/Tpl/Public$ lshead.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>

0 0