您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息
免费发信息

TP3.2.3 亲测自定义标签通用代码

2024/4/18 16:03:05发布6次查看
3.2.3自定义标签通用代码(新手第一次发)
标签库代码: array('attr' => 'type,order,limit,where','close' => 1),
    );
    public function _list($attr,$content) {
        $type = $attr['type']; //要查询的数据表
        $order = $attr['order'];    //排序
        $limit = $attr['limit']; //多少条数据
        $where = $attr['where']; //查询条件
        $str = 'where(' . $where . ')->order(' . $order . ')->limit(' . $limit . ')->select();';
        $str .= 'foreach ($result as $v):';
        $str .= '?>';
        $str .= $content;
        $str .= '';
        return $str;
    }
}调用代码:
{$v[id]} -- {$v[user]}
注意:where 的条件字符串要有单引号,另外{$v[id]}要这样写,如果写成{$v:id}无效.该文件与cx标签库放在同一个文件夹下...修改thinkphp文件夹下通用配置文件. 新手第一次发,研究了三天,如果有任何bug,请及时告知..谢谢.
ad:真正免费,域名+虚机+企业邮箱=0元
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录