Is there a way to remove the lock badge for some categories but not for others?

Hello guys,

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.

Thanks a lot!

edit:
I read both of the following threads, but could not find a solution that worked for me:

I think this should do it:

// 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!

11 Likes

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.

Hi, what about this:

.category-drop [data-value="ID"] .restricted,
[href^="/c/off-topic"] {
    .d-icon-lock {
        display: none;
    }
}

Replace ID with the off-topic category ID.

1 Like

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 made a typo in the CSS; I wrote lounge instead of off-topic.

1 Like

this is exactly what i want to do.

fantastic! that did it. thank you so much :clap:

2 Likes

Glad it worked! Let me know if I missed a location :slight_smile:

2 Likes

@Arkshine
Using the code examples above, I was able to remove the lock for 2 categories on the main homepage and on the sidebar. Awesome!

However, the lock still appears on the category drop down menus. Both of these cateogies show no locks anywhere else, just in this menu.

Any ideas?

EDIT:

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:

.badge-wrapper.bullet span.badge-category, {
    .d-icon-lock {
        display: none;
    }
}

I tried using a similar CSS as above using the [data-value=“ID”] but that didn’t work in this instance.

1 Like

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. :slight_smile:

2 Likes

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.

1 Like

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. :blush:

2 Likes