Is there any way to remove subcategories from the hamburger menu

in the meta drop down menu next to user avatar, only categories are shown . This keeps the menu clean .

I couldn’t find any option in the setting searching for subcategory, how can I remove subcategories from the menu?

2 Likes

I guess I’m not understanding what you’re saying. The categories that show in the hamburger menu display all the categories I have permission to. Both parent categories and child categories.

You’re looking for this setting: Show subcategory list instead of topic list when entering a category.

Strangely, as far as I can tell, this controls both the display of subcategories in the hamburger menu, and whether they appear in the topic list - they can’t be controlled independently.

1 Like

You don’t see this subcategory in the dropdown? extras - Discourse Meta

He is trying to hide them. I think…

Taking Meta as an example, he wants to hide the highlighted items

1 Like

Thanks for the screenshot! Yes I think he wants to hide them

but its looks like meta is also showing subcategories so we aren’t doing anything special either to show only categories. You will probably have to do some css magic, create a plugin, or create a setting for this and make a pr.

I’m confused, does the site setting I mentioned above not work? It seems to work fine for me…

Enabled:

Disabled:


Edit: Keep in mind, it’s also affecting the following…

Enabled:

Disabled:

3 Likes

Works on my sandbox (never knew that setting also controlled that list)

@blake, can I infer from your post that separating the hamburger list and the topic list subcategory settings would be #pr-welcome?

What feature exactly are you asking for?

A discreet site setting for “hamburger only shows top level categories” ?

3 Likes

Yes. I’d like to be able to control the hamburger menu independently of the topic list.

3 Likes

A pr that adds the .subcategory class to the enclosing LI is welcome. Then you can do it with CSS.

A site setting is @codinghorror’s call

5 Likes

I’ll take a stab at it after work.

1 Like

For reference, this is the file in question
https://github.com/discourse/discourse/blob/master/app/assets/javascripts/discourse/widgets/hamburger-categories.js.es6

3 Likes

OK - so I’ve been digging into this for quite some time now. First time working with widgets, so it took me some time to wrap my head around how everything works.

It looks like @neil committed a new feature that changes the way this works about 12 hours before @Pad_Pors’s first post. I believe this commit explains why we’re now seeing subcategories in the Meta hamburger menu. Primarily, the site setting I mentioned above doesn’t exist anymore. Secondly, I believe the commit as it currently stands is broken. Here’s the commit:
https://github.com/discourse/discourse/commit/a702330ccdfa46a3e110f4df852f451975c51d30

The commit appears to remove the site setting in favor of a per-category setting.

Here’s the line that I believe is broken (no idea how to fix it):
https://github.com/discourse/discourse/blob/master/app/assets/javascripts/discourse/widgets/hamburger-menu.js.es6#L123

If I understand correctly, it says that “if the current category has show_subcategory_list enabled and the category has a parent category, return true”, and thus don’t add said category to the list. The problem is only a parent category can have the show_subcategory_list setting enabled, and parent categories can’t have parents, so this will never be true. It should be “if the current category’s parent has show_subcategory_list enabled and …”

I’ve still not figured out how to modify the CSS for subcategories only, but before I continue working I wanted to ensure my understanding of the code is correct, and ensure I’m hacking at working code.

6 Likes

Probably a bug, @neil will look at it Monday when he is back.

3 Likes

Yeah that was a bug. Fixed!

5 Likes

I have upgraded to latest but I can’t fine this setting yet, should I wait more or is this option gone?

  • I can see the hamburger menu of meta is clean again, so I guess there should be a way to activate this now. is there?

It is on each Category. So visit the Category, choose Edit Category, and it should be in one of the tabs.

5 Likes

I am having a similar difficulty. The hamburger menu is showing ALL my categories (including subcategories). I went in to the categories that have subcategories and selected subcategory list. That changed the category pages, but not the hamburger menu. So I’m not sure what to do.