Category Hider Theme Component

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 Likes

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

5 Likes

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 Likes

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 Likes

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 Likes

Hi this seems to be broken after latest discourse update.

1 Like

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

2 Likes

Hey @Heliosurge,

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

3 Likes

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

One member @nolo 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 Likes

@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 Likes

Awesome! Thank you keep up the fantastic work.

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

1 Like


Hello @keegan
Can we hide Category in Top menu?
Thank you!

I get the following error when installing (on 3.1.0beta3):

Error: expected “]”. ┌──> /tmp/discourse_theme_526e702e5adb76bf8137c869c5f6d389/discourse-category-hider/stylesheets/mobile/categories.scss 6 │ [data-category-id=‘#{$box}’] { │ ^^^^ ╵ ╷ 1 │ [data-category-id=“str-split(, “|”)”] │ ━ error in interpolated output ╵ mobile/categories.scss 6:26 @import /var/www/discourse/mobile.scss 1:993 root stylesheet

2 Likes

yes this would be useful except the install is now broken for latest Discourse version.

I’ve just pushed out a fix, please try installing again/updating the component.

I’ve just added this feature. You can now add the category name to the category_breadcrumb theme setting to hide certain categories from the category breadcrumb dropdown.

5 Likes

Excusme, but not effect


Am i right?

1 Like

Make sure you use the Category’s name for this one, not the category slug.

3 Likes

Thank you,
Success,
Everyone, notice Uppercase or lowercase

4 Likes

Hi

This component works well in the standard Category screen and Breadcrumb, however:

It doesn’t remove the categories from the hamburger menu, unless the sidebar is set to legacy.

Is there a way to hide the categories in the standard sidebar/hamburger?

I have tried the “category hamburger” setting, but cannot seem to get it to work.

Thanks

2 Likes

Hi @martyn_thomas

you can set the categories in the navigation menu with admin-settings - default_navigation_menu_categories - this setting allows you to select which categories will be displayed under the Navigation Menu’s Categories section by default. Users can override this and customize their own category menu section by clicking the pencil icon next to the Categories header just like you can, and this should generally be encouraged.

2 Likes