Taglib新用法,可能是原创

浏览:1677 发布日期:2013/09/11 分类:技术分享
大家是不是都喜欢Widget,而不是很喜欢自定义标签?因为定界符输出html,还要大量转义不是很方便,其他不用这么麻烦,使用定界符输出php代码,php负责输出对应数据即可,tpl照样直接取数据。<?php
class TagLibMytags extends TagLib{
    
    protected $tags=array(
        "pdlist"=>array(
            "close"=>0,
            "attr"=>"pid",    
        ),
    );
    
    public function _pdlist($attr){
        $html_str=<<<Eof
<?php        
        
        \$pdinfo=M("Pdinfo");
        \$where=array("belongproduct"=>\$pro["id"]);
        \$infores=\$pdinfo->where(\$where)->select();

?>
Eof;
    return $html_str; //输出数据即可
    }    
    
}
最佳答案
评论() 相关
后面还有条评论,点击查看>>