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元