Maison  >  Article  >  php教程  >  thinkphp3.2自定义模板标签详解TagLib

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

WBOY
WBOYoriginal
2016-06-07 11:37:511364parcourir

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元

Déclaration:
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn