场景需求
有些博主想要做一些特殊的需求,比如本站,摄影模块就是特殊处理,摄影分类并不在首页展示。
解决方案
- 步骤一:隐藏侧边栏的分类
找到主题下的sidebar.php文件,找到代码$this->widget('Widget_Metas_Category_List')
修改为$this->widget('Widget_Metas_Category_List@options','ignore=13')
其中13为想要隐藏分类的mid - 步骤二:隐藏首页文章列表的摄影分类文章
采用插件CateFilterhttps://github.com/typecho-fans/plugins/tree/master/CateFilter
隐藏,启动插件后,设置首页想要隐藏的分类的mid即可 - 步骤三:隐藏文章详情中上一篇下一篇中的摄影分类文章
找到/var/Widget/Archive.php
文件,修改thePrev
和theNext
方法
thePrev方法$content部分代码替换如下,13为摄影分类mid
$content = $this->db->fetchRow($this->select()->from('table.contents')
->join('table.relationships', 'table.relationships.cid = table.contents.cid')
->where('table.relationships.mid != ?', '13')
->where('table.contents.created < ?',$this->created)
->where('table.contents.status = ?', 'publish')
->where('table.contents.type = ?', $this->type)
->where('table.contents.password IS NULL')
->order('table.contents.created', Typecho_Db::SORT_DESC)
->limit(1));
theNext方法$content部分代码替换如下,13为摄影分类mid
$content = $this->db->fetchRow($this->select()
->join('table.relationships', 'table.relationships.cid = table.contents.cid')
->where('table.relationships.mid != ?', '13')
->where('table.contents.created > ? AND table.contents.created < ?',$this->created, $this->options->time)
->where('table.contents.status = ?', 'publish')
->where('table.contents.type = ?', $this->type)
->where('table.contents.password IS NULL')
->order('table.contents.created', Typecho_Db::SORT_ASC)
->limit(1));