类别隐藏主题组件

Hi all, I’ve created a simple theme component. I hope this could be of use for some!

:eyeglasses: Overview

This is a theme component that allows you to hide specific categories from either the hamburger menu or category boxes.

:thinking: Why would you need this component?

If your discourse website has a lot of categories and you would like to hide some from appearing in either the menu bar or on the main page, this component can be helpful.

:framed_picture: Screenshots

Preview of Hamburger Menu: Before → After

:gear: Settings Menu:

More details on how to use this theme component and installation instructions are available at the component’s GitHub repository.

14 个赞

This looks pretty cool, but what advantage does it give you over muting a category?

5 个赞

Correct me if I’m wrong, but from what I understand is that when I mute a category it basically means no notifications? :thinking: When I tried muting a category it still appears in the hamburger menu and category boxes.

This theme component is more of a stylistic change. It hides desired categories visually, but still keeps notifications and all other functionality for the category intact.

2 个赞

This only occurs (I think) if the user has a topic in one of those categories that is unmuted.

Your component would prevent that occurring, which could be helpful in situations where you really want to suppress the category and keep things tidy.

4 个赞

Hey keegan,

this component looks exactly like something we need in the future. Our use case is very specific in which we want to hide sub-categories from one specific parent category.

In combination with the code snippet from here this might achieve exactly what we are looking for:

2 个赞

Hi this seems to be broken after latest discourse update.

1 个赞

@Heliosurge Thanks for letting me know, will fix this as soon as I can and will post an update here.

2 个赞

Hey @Heliosurge,

The issues with the theme component are now fixed. It should be working correctly now.

3 个赞

Thank you Keegan. An interesting idea as had posted a help topic as had used css prior to accomplish this.

One member @manuel had given me a great piece of css as I was using this to hide many subcategories so only Parents show in hamburger.

So as a Though maybe adding a toggle to hide just subcategories.

.hamburger-panel .category-link.subcategory {
      display:none;
}

This setting can make things very convenient if ppl have alot of subs to hide.

4 个赞

@Heliosurge

Sounds very convenient! Thanks! I’ve added that now to this theme component, so you can now toggle the ability to hide subcategories in the hamburger menu and/or category-list context.

3 个赞

Awesome! Thank you keep up the fantastic work.

:beers::sunglasses::+1::sparkles:

1 个赞


你好 @keegan
我们可以在顶部菜单中隐藏类别吗?
谢谢!

安装时出现以下错误(在 3.1.0beta3 上):

错误:预期为“]”。 ┌──> /tmp/discourse_theme_526e702e5adb76bf8137c869c5f6d389/discourse-category-hider/stylesheets/mobile/categories.scss 6 │ [data-category-id=‘#{$box}’] { │ ^^^^ ╵ ╷ 1 │ [data-category-id=“str-split(, "|")”] │ ━ 插入输出错误 ╵ mobile/categories.scss 6:26 @import /var/www/discourse/mobile.scss 1:993 root stylesheet

2 个赞

是的,这会很有用,只是最新 Discourse 版本的安装现在已损坏。

我刚刚发布了一个修复程序,请重试安装/更新组件。

我刚刚添加了此功能。您现在可以将类别名称添加到 category_breadcrumb 主题设置中,以从类别面包屑下拉菜单中隐藏某些类别。

5 个赞

抱歉,但没有效果


我说得对吗?

1 个赞

请确保您在此处使用分类的名称,而不是分类的 slug。

3 个赞

谢谢,
成功,
大家注意大写或小写

4 个赞

你好

此组件在标准的 Category 屏幕和 Breadcrumb 中运行良好,但是:

它不会从汉堡菜单中移除类别,除非侧边栏设置为旧版。

有没有办法在标准的侧边栏/汉堡菜单中隐藏类别?

我尝试过“category hamburger”设置,但似乎无法使其正常工作。

谢谢

2 个赞

您好 @martyn_thomas

您可以在导航菜单中通过管理员设置 - default_navigation_menu_categories 来设置类别 - 此设置允许您选择默认情况下将在导航菜单的类别部分下显示的类别。用户可以通过点击类别标题旁边的铅笔图标来覆盖此设置并自定义自己的类别菜单部分,就像您一样,并且通常应鼓励这样做。

2 个赞