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

浏览:2512 发布日期:2015/07/25 分类:用法示例 关键字: thinkphp 自定义模板标签 TagLib 3.2
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;    
use Think\Template\TagLib;
三、class名

3.1的命名 class TagLibShop extends TagLib

3.2的命名 class Shop extends TagLib


四、标签属性读取

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