设计,技术,行业
/**
* 获取文章关键字标签
* @param int $id 文章id
* @return array 标签组
*/
public static function tags($id)
{
$list = Db::name('portal_tag_post')->alias('p')
->join('__PORTAL_TAG__ t', 'p.tag_id=t.id', 'left')
->field('p.tag_id,t.name,p.post_id')
->where('t.status=1')
->where('p.post_id='.$id)
->limit(5)
->select();
return $list;
}
存放路径:/app/portal/service/ApiService.php
list列表页中使用:
<php>
$tags=\app\portal\service\ApiService::tags($vo['id']);
</php>
<volist name="tags" id="vo">
<a href="{:cmf_url('portal/tag/index',array('id'=>$vo.name))}">{$vo.name}</a>
</volist>
$vo['id']为文章id。