Home > php教程 > php手册 > body text

thinkphp3.2自定义模板标签详解TagLib

WBOY
Release: 2016-06-07 11:37:51
Original
1359 people have browsed it

thinkphp3.2自定义模板标签详解TagLib
关于标签写法在这里不再重复,点击查看3.1版本说明http://www.thinkphp.cn/topic/31574.html
3.2引入方法基本与3.1相似下面介绍区别

一、存储位置

在3.1中 网站目录\Lib\TagLib 命名格式:"TagLib"+"Shop"+".class.php",
在3.2中 框架目录\Library\Think\Template\TagLib 命名格式 "Shop"+".class.php"

二、文件命名空间

在3.1中是不需要命名空间
在3.2的文件中开头需要加上如下代码namespace Think\Template\TagLib;    <br> use Think\Template\TagLib;三、class名

3.1的命名 class TagLibShop extends TagLib

3.2的命名 class Shop extends TagLib


四、标签属性读取

3.1的读取方式//标签传入参数为$attr<br> public function _shoplist($attr,$content){<br>     $attr = $this->parseXmlAttr($attr);  //使用继承方法读取参数<br>     $id = $attr['id'];<br> }3.2的读取方式//标签传入参数为$tag<br> public function _shoplist($tag,$content){<br>     $id = $tag['id'];  //直接获取属性<br> }加载扩展标签与3.1一样,这里就不再细表。
原位置 http://www.90coder.com/Home/Index/article/tid/39.html

AD:真正免费,域名+虚机+企业邮箱=0元

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!