as the title suggests, I am looking for a way to remove the lock badge for some categories, but not for others.
I managed to do this for the category-drop-header, since I can use the category ID to only remove the lock icon for this category, instead of globally.
I did not, however, manage to remove the icon for the badge in the category overview (cf. screenshot) and in the drop-down list of categories in the search.
Do you have any suggestions for me? I’m pretty new to working with CSS and I’ve exhausted my own approaches.
// Hide the lock icon for specific categories on topic lists and hamburger menu,
// and hide the lock icon on all dropdown search results
.search-menu .results .restricted,
[href="/c/MY-CATEGORY-SLUG1"],
[href="/c/MY-CATEGORY-SLUG2"],
[href="/c/MY-CATEGORY-SLUG3"] {
.fa-lock {
display: none;
}
}
Just replace the MY-CATEGORY-SLUG# part with the slugs of the categories you want to have the lock icon hidden.
Unfortunately there isn’t enough to work with in the HTML to pick and choose which categories show the lock icon in the dropdown search results with CSS, so it’s all or nothing for that part. You will need to decide if you want to show or hide the lock for all restricted categories. If you want to show it, just remove this part: .search-menu .results .restricted,
Hopefully that gets you pretty close to what you are looking for!
ok apologies for the necro, but i can’t seem to get this one to work. i’m trying to suppress the lock icon for our Lounge which has the slug “off-topic”. our Lounge wasn’t the default install, it was a created category and i have set permissions so that it isn’t viewable to non-members. but i don’t want the lock icon there because membership thinks it is a locked category.
i’m assuming i add this to the CSS code:
// Hide the lock icon for specific categories on topic lists and hamburger menu,
// and hide the lock icon on all dropdown search results
.search-menu .results .restricted,
[href="/c/off-topic"] {
.fa-lock {
display: none;
}
}
the lock icon is still there. i don’t want to replace it globally and i like the idea of suppressing the lock icon in the category drop-down as well.
thank you for the reply. that suppressed it in the category search drop down, which is great. but i also want to suppress the lock icon globally for that category (not other locked elements), like on the category list page.
I was able to remove the lock icon from the drop-down menus for ALL categories, but I can’t figure out how to remove it for only selected categories. Here’s the CSS:
I notice using CSS on lock icons is a bit tricky in places, so I made a theme component to easily accomplish this and it hides the lock icon for selected secure categories in the breadcrumb dropdown selector, the header bar breadcrumb, navigation sidebar menu, and corresponding chat channels.
Thanks @Lilly . I saw your original response the other day and just now had time to do some edits, and came to find that you not only made it easier for me to do, but created an excellent theme component that will surely help countless people trying to accomplish the same thing. Thanks so much for your time and effort on this. Much appreciated.
You’re very welcome and thank you for the lovely compliment. I quite enjoying developing theme component tools to help people extend the capabilities of their Discourse forums.