1.前端调用
列表调用: {listarticle columnid="1" row="10"} <a href="{$newslist.url}a_id={$newslist.a_id}">{$newslist.a_title}</a> {/listarticle}
2.标签库
// 内容列表查询 public function tagListarticle($tag,$content){ $result= !empty($tag['result'])?$tag['result']: 'newslist'; $app = 'appindexfacadeCat'; $ids = empty($ids) ? $tag['columnid'] : $tag['columnid'].','.$ids; $column=$tag['columnid']; $map.= $column?" a_columnid in (".$ids.")":"1"; $sql ="db('article')->"; $sql.=($tag['field'])?"field('a_id,a_title,a_pic,a_time,a_columnid,{$tag['field']}')->":"field('a_id,a_title,a_pic,a_time')->"; $sql.="where("{$map}")->"; $sql.=($tag['order'])?"order('{$tag['order']}')->":"order('a_id desc')->"; $sql.=($tag['group'])?"group('{$tag['group']}')->":""; $sql.=($tag['num'])?"limit({$tag['num']})->":""; $sql.="select()->toArray()"; $empty = isset($tag['empty'])?$tag['empty']:''; //下面拼接输出语句 $parsestr = '<?php $_result=htmlOutList('.$sql.',false);'; $parsestr .= 'if($_result)'; $parsestr .= 'foreach($_result as $key=>$'.$result.'):?>'; $url = "getListUrl($newslist)"; $spic = "getSpic($newslist)"; $parsestr .= '<?php $'.$result.'["url"]='.$url.'; $'.$result.'["a_pic"]='.$spic.'; ?>'; $parsestr .= $content;//解析在article标签中的内容 $parsestr .= '<?php endforeach;else?>'; $parsestr .='<?php echo "'.$empty.'";?>'; return $parsestr; }
3.实现的效果,点击标题进入查看内容,样式不用管这里只负责实现功能