Hiding categories from the drop down menu?

(Rob Meade) #1

Hi all,

We are implementing some css to hide a couple of categories from the main categories view, compliments of @awesomerobot (here) but I realised yesterday that they are also in this drop down menu;


…and of course they also appear in the drop down menu for creating a new topic;


Can anyone offer a way to hide these also perhaps with css again?

On a related note, is there any likelihood of seeing the “Is Hidden” option returning? Whilst the css approach works, this would now mean we are targetting three specific areas of Discourse using css as a bit of a hacky/fixy approach. I know we could just delete the categories, but the decision has been made (not by myself) to retain them for the time being, which is also a valid option, we just don’t want to see them :slight_smile:

Removal of Category Permissions Quirk
(Justin DiRose) #2

You could add some CSS like this:

.category-drop .select-kit-body li[title="<category name>"], 
.category-input .select-kit-body li[title="<category name>"] {
    display: none !important;

The title is an attribute on the category li element, so to hide it you’d need to make sure it exactly matches the category name when adding it into the rule for it to apply.

If you’re looking to keep the categories, but have them not publicly visible, you could also set the permissions to staff-only for the category as well. The content will still be there but not visible to anyone not in the staff group.

(Robert McIntosh) #3

Can I ask why you don’t just change the category security permissions so only Admins can SEE the category? Then they will not appear in any list for any user other than staff

Are you still going to show the contents to anyone?

(Rob Meade) #4

Thanks both for the replies.

The original issue (term used loosely) started when the “Is Hidden” option was removed from the settings, from memory, and excuse me if I am wrong (it was a while back), this didn’t show the category to anyone, but it still remained, so if we wanted to turn it back on in the future we could do so and retain the posts and so on. The benefit of this was that staff didn’t see it in the normal day-to-day use of the site either, but they were still accessible via settings etc.

After the change, a post or two led to the use of the css to hide the categories from the latest view, and subsequently, via mobile also. So we were back to having a scenario where no one could see them, but they still appeared in the settings.

I like the idea of using the permissions, from the perspective of simplicity and just the one switch to make a change so to speak, but obviously the downside is that it will clutter up our own use of the forum. I appreciate I could bump them to the bottom of the list and so on to make them more out of the way, but then we’re back in the realms of hacky/fixy rather than solution :slight_smile:

The categories were for courses that were being offered, currently, these courses have been suspended, and I’m not personally in a position to say/know whether they will come back - I suspect this is part of the reason there is a desire to retain the content rather than just delete it. (deleting it would have been my own personal preference initially, but that’s not my call).

I’m assuming there is no way to remove all permissions so that no one can see them, and at the same time not screw up the settings, e.g. in such a way that permissions couldn’t later be added back? Just a thought, as that would then work in the manner @robmc describes, but also for the benefit of staff. Kind of manageable but not visible.

Thanks again for the replies. :slight_smile:

September 20, 2018 8:56 PM (Europe: Paris), September 20, 2018 11:56 AM (America: Los Angeles)

@justindirose - just a thought based on something you mentioned above;

The content will still be there but not visible to anyone not in the staff group.

I could potentially create a group then, let’s call it “HiddenCategories”, set it as the only group to have access to a category, and then ensure that no one is a member of it? If I wanted to then see a hidden category later, I could add myself to the “HiddenCategories” group and it would appear in my views. If we ever decided to bring the category back to life so to speak, we could then just assign the normal groups permissions and remove the “HiddenCategories” group.

Do you think that would work?

(Justin DiRose) #5

That’s essentially what I was recommending, yes. You could create a specific group for that, or use one of the built-in ones. That choice is up to you.

(Rob Meade) #6

Thanks Justin, I will give this a try this evening and see what happens. :slight_smile:

(Rob Meade) #7

Sadly it doesn’t work.

I created a group called “HiddenCategory”, set it to only be visible by Admins and Staff, added no members. Created the group (after some significant issues with the validation).

It automatically added myself, as the owner, despite not setting myself as a member. I removed myself.

Viewed the settings for one of the categories to hide, added the new group and set the permissions to “See”. Removed the “Everyone” group. Saved the settings.

Browsed to the “Latest View”. The category is still displayed within the drop down menu, presumably because I am an admin on the site. It does however have a padlock against it, which suggests that normal community members would no longer see it.

Removal of the previous css entries to hide the categories from the “Latest View” made them visible again. The category in question had a padlock against it, so again I can assume it would not be visible to normal community members, but it is still visible to myself.

It looks like I can use a combination of the new group and permissions to hide the categories from the drop down menu(s), but not from staff, and also css to hide the categories from the “Latest View” for everyone. Effectively, the same as assigning “Staff” as the permissions, or, having none at all.

Still not quite perfect as solutions go sadly :frowning:

(Justin DiRose) #8

If you are looking to have only Admins view it, set the permissions to “Admins” instead of “Staff”. It won’t be visible to anyone except an admin account. Admins will see it with a lock icon as you described.

(Rob Meade) #9

The hope was to hide it from everyone, but as the only way for admin staff to edit the permissions and settings is via seeing the category in the same way a normal user would I don’t think its going to be possible.

Not to worry, thanks for your help Justin, appreciated.

(Robert McIntosh) #10

How many admins do you have? Admins will always see it whatever the setting but if it is 5 or 10 people, surely all this work is completely over the top?

(Rob Meade) #11

Yeah probably, but I’m on the site every day and I prefer to work in a clutter free environment if I can, so I’m stuck between not being able to delete the categories, and not being able to hide the categories.

I get that it can’t be achieved without the css, and having to use that with specific names isn’t ideal as it’ll break the moment someone renames something, will just have to plod on as is. Thanks for your time though Rob.