理论上后台文章状态关闭了,那么前台的这篇文章生成出来的tag就应该消失掉,但是现在pbootcms默认的并没有根据文章状态显示隐藏。在平时一般使用中可能影响不大,但是碰到类似本站右侧有tags列表展示,而且还配了数量显示,那么当用户看到明明显示有数量点击进去却没有,这种体验效果就很差。那么现在就来讲下如何修复这个问题,实现tag标签可以随文章状态实现显示和隐藏。
实现方法
打开这个文件 \\apps\\home\\model\\ParserModel.php,找到getSortTags($scode)截图这个位置
在其最后找到
$result=parent::table('ay_contenta')->where("c.type=2ANDa.tags<>''")
->where($scode_arr,'OR')
->join($join)
->order('a.visitsDESC')
->column('a.tags');
return$result;
将其修改为以下,保存即可
$result=parent::table('ay_contenta')->where('a.status=1')->where("c.type=2ANDa.tags<>''")
->where($scode_arr,'OR')
->join($join)
->order('a.visitsDESC')
->column('a.tags');
return$result;
方法解读
上面的方法是给去数据库查找的时候增加了个状态判断where('a.status=1')