zoukankan      html  css  js  c++  java
  • ThinkPHP 3.1.2 模板的使用技巧

    本节课大纲:
    一、模板包含
    		<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:wampwww	hinkphp2ThinkPHPLibCoreAction.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>
    

  • 相关阅读:
    使用squid代理后某些网站无法访问的解决办法(3.1.7版本)
    如何高效设计游戏——从抽奖模型到圆桌算法(下)附VBA教程&战斗模拟器
    squid代理服务器泄露客户ip和服务器信息的解决
    分享squid缓存服务器配置之conf配置文件的详细介绍
    如何高效设计游戏——从抽奖模型到圆桌算法
    在linux下成功使用西部数据高级格式化的硬盘
    squid 高级篇
    squid禁止多线程并发下载的简单方法
    jquery实现搜索框类似提示功
    关于phoneGap camera照片放置的位置问题
  • 原文地址:https://www.cnblogs.com/zhaoyangjian724/p/6200151.html
Copyright © 2011-2022 走看看