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

实现方法

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

image.png

在其最后找到

  1. $result = parent::table(\’ay_content a\’)->where(“c.type=2 AND a.tags<>\’\'”)
  2.     ->where($scode_arr, \’OR\’)
  3.     ->join($join)
  4.     ->order(\’a.visits DESC\’)
  5.     ->column(\’a.tags\’);
  6. return $result;

将其修改为以下,保存即可

  1. $result = parent::table(\’ay_content a\’)->where(\’a.status=1\’)->where(“c.type=2 AND a.tags<>\’\'”)
  2.     ->where($scode_arr, \’OR\’)
  3.     ->join($join)
  4.     ->order(\’a.visits DESC\’)
  5.     ->column(\’a.tags\’);
  6. return $result;

方法解读

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

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注