Typecho不显示(隐藏)某个特定分类

最近在对钛导航
进行改版,需要实现不显示某个特定分类的功能,查看typecho官方文档毫无头绪,在网上查询到的代码也无法实现隐藏分类功能,最后误打误撞实现。
typecho现有的输出所有分类
$this->widget('Widget_Metas_Category_List')
网上查到的相关代码,其中ignore
表示要隐藏的分类mid
$this->widget('Widget_Metas_Category_List','ignore=1')
但通过上面的代码无法实现隐藏功能,查看系统文件,最后在/var/Widget/Metas/Category/Edit.php中看到了下面这段代码
/** 父级分类 */
$options = array(0 => _t('不选择'));
$parents = $this->widget('Widget_Metas_Category_List@options',
(isset($this->request->mid) ? 'ignore=' . $this->request->mid : ''));
while ($parents->next()) {
$options[$parents->mid] = str_repeat(' ', $parents->levels) . $parents->name;
}
这代码看着很熟悉有木有,上面有个@options的字符串不知道是啥,毕竟PHP盲,尝试把@options加进去,KO,搞定!
最后的代码
<?php $this->widget('Widget_Metas_Category_List@options','ignore=1')->to($categories); ?>
如需隐藏多个分类,请参考:https://www.seo135.com/seogo/1193.html
文章评论 (5)
-
可以隐藏多个分类吗?
-
感谢分享。
-
.... 原来可以这样 mark 转载~
-
博主是PHP盲吗,Hhh
-
@Alone88人艰不拆-_-#
-