河北pbootcms文章状态为关闭时tag标签依旧显示

pbootcms文章状态为关闭时tag标签依旧显示怎么解决?

理论上后台文章状态关闭了,那么前台的这篇文章生成出来的tag就应该消失掉,但是现在PbootCMS默认的并没有根据文章状态显示隐藏。在平时一般使用中可能影响不大,但是碰到类似本站右侧有tags列表展示,而且还配了数量显示,那么当用户看到明明显示有数量点击进去却没有,这种体验效果就很差。那么现在就来讲下如何修复这个问题,实现tag标签可以随文章状态实现显示和隐藏。

实现方法

打开这个文件 \apps\home\model\ParserModel.php,找到getSortTags($scode)截图这个位置

在其最后找到

$result = parent::table('ay_content a')->where("c.type=2 AND a.tags<>''")
    ->where($scode_arr, 'OR')
    ->join($join)
    ->order('a.visits DESC')
    ->column('a.tags');
return $result;

改成

$result = parent::table('ay_content a')->where('a.status=1')->where("c.type=2 AND a.tags<>''")
    ->where($scode_arr, 'OR')
    ->join($join)
    ->order('a.visits DESC')
    ->column('a.tags');
return $result;

上面的方法是给去数据库查找的时候增加了个状态判断where('a.status=1')

文章标签:河北pbootcms教程河北pbootcms技巧