理論上后臺(tái)文章狀態(tài)關(guān)閉了,那么前臺(tái)的這篇文章生成出來(lái)的tag就應(yīng)該消失掉,但是現(xiàn)在PbootCMS默認(rèn)的并沒有根據(jù)文章狀態(tài)顯示隱藏。在平時(shí)一般使用中可能影響不大,但是碰到類似本站右側(cè)有tags列表展示,而且還配了數(shù)量顯示,那么當(dāng)用戶看到明明顯示有數(shù)量點(diǎn)擊進(jìn)去卻沒有,這種體驗(yàn)效果就很差。那么現(xiàn)在就來(lái)講下如何修復(fù)這個(gè)問題,實(shí)現(xiàn)tag標(biāo)簽可以隨文章狀態(tài)實(shí)現(xiàn)顯示和隱藏。
實(shí)現(xiàn)方法
打開這個(gè)文件 \apps\home\model\ParserModel.php,找到getSortTags($scode)截圖這個(gè)位置

在其最后找到
$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;
|
方法解讀
上面的方法是給去數(shù)據(jù)庫(kù)查找的時(shí)候增加了個(gè)狀態(tài)判斷where('a.status=1')