onethink封装arclist调用文章列表!
其实没有什么东西,做个记录,方便以后使用!
<ul> <arclist mid='2' cid='2' row='2'> <li>{$title}</li> </arclist> </ul>
封装标签示例:
// 定义标签 protected $tags = array( 'topcates'=> array('attr'=>'limit'), 'arclist'=> array('attr'=>'mid,cid,row') );
具体方法示例:
public function _arclist($attr,$content){ //调用父类 $mid = isset($attr['mid']) ? $attr['mid'] : '2'; $cid = isset($attr['cid']) ? $attr['cid'] : ''; $row = isset($attr['row']) ? $attr['row'] : '5'; // 组合PHP代码字符串 $str = '<?php '; $str .= '$where = array("model_id"=>'.$mid.',"category_id"=>'.$cid.');'; $str .= '$_cateArcList = M("document")->where($where)->limit('.$row.')->select();'; $str .= 'foreach($_cateArcList as $v):'; $str .= 'extract($v); ?>'; $str .= $content; $str .= '<?php endforeach;?>'; return $str; }
just so so !