Category Icons

what does “icon” stand for in settings?

Is it exact name of some icon from svg site? How do I get the exact name?

1 Like

That could indeed be a great improvement!

1 Like

I think I have a problem on my forum as the icons are specified as white, while background is white on categories page

Could I enforce different background here, as it is used for subcategories?

2 Likes

I’m looking at the code and trying to fix the following two issues, but I’m stuck on the second one.

Category icon list is not applied in category view (with Show subcategory list above topics in this category)

subcategory-view-missing-category-icon

I managed to fix this one by replacing line 112 in header.html

      if(iconItem && !attrs.category.parent_category_id) {

with

      if (iconItem) {

and adding the following code to common.scss

.subcategory .category-icon-widget {
  display: none;
}

subcategory-view-missing-category-icon-fixed

Category lock icon next to category doesn’t change to new svg

Categories view:
category-view-lock-icon

Category view (with Show subcategory list above topics in this category):
subcategory-view-lock-icon

I think this is the relevant code:

    let classNames = "badge-category clear-badge";
    if (restricted) {
      classNames += " restricted";
    }
    
...

    html +=
      `<span ${style} ` +
      'data-drop-close="true" class="' +
      classNames +
      '"' +
      (description ? 'title="' + escapeExpression(description) + '" ' : "") +
      ">";

which adds restricted class to a <span> with classes badge-category clear-badge which controls the subcategory lock icon display, but I cannot figure out how to also apply this to <div> with class category-text-title which controls category lock icon display.

Please help @pmusaraj @tshenry

2 Likes

Any chance that it will anytime soon? For some reason the categories boxes view also doesn’t display the colour blob or the lock icon so it might be outside this component’s control…

1 Like

I’m still not able to “figure out” what is wrong with the color,
Someone can help me where I was wrong?

and the result

1 Like

Bug @pmusaraj
Sub-Category slugs (and titles) only have to be unique within their parent category

But slugs are used as the key to find the icon in this component.

Thus if you have two subcategories under different parents that have the same slug the icon is applied to both of them.

To be honest I think this is actually a Discourse problem as slugs should be unique across the whole discourse instance, but they are not.

Is it even possible to fix this within the component?

1 Like

I don’t understand why the slugs need to be globally unique when, AFAIK, they never have a global scope. Can you explain?

P.S. I see your new topic which asks the question why they aren’t unique.

1 Like

The Category Icons Component for example uses the slug to identify the category to which the icon has to be attached.
How is an admin or user to uniquely identify a subcateogry? - do they have to use the path parentcategory-subcategory? (or parent-child-grandchild when that enhancement gets released). This seems a bit cumbersome.

2 Likes

It is likely possible to have the component deduplicate subcategories with the same slug under different parents but it would require some way to pass the parent category slug in the component’s settings. IMO it would not be too elegant.

Can you try changing the slug for one of the two categories that have the same slug? Is there a reason you can’t do that (just the slug needs to change, not the category name)?

3 Likes

Yep, that seems to be the way to go given that sub-category slugs in different parent categories do not not have to be unique.

Having said that, it can actually be turned to advantage as a feature. For example if you have group based categories many of which have a help and announcement forums as subcategories then you can easily set up a common help icon for all the help categories and a common icon for all announcement categories using just two entries. And any new subcategories with the help tag would pick up the icon automatically.

For our use I have taken this one stage further and actually made it an option for a partial match on the slug so that an entry “help,question-mark,#000080,false” would match “sw-help” and “help-forum” and “helpdesk”.

The “false” additional item on the end of the entry tells it not to enforce an exact match.

I also have the option to specify the colour as “catcol” in which case the icon will pick up the category colour instead of using a separate specified one.

Two suggestions for inclusion in an update for you.

3 Likes

I think the component used a partial match at some point, and it was confusing to some users who wanted an icon for “book” but not for “booking”. But with the option to turn this on/off per setting, this would be nice. (Maybe you could use partial-match instead of false as the last item, would be easier to understand.)

That’s a nice addition.

I would be happy to review a PR for either of these features. Thanks!

5 Likes

https://github.com/pmusaraj/discourse-category-icons/pull/5 has been merged, thanks @rogerco!

3 Likes

I’ve come up against a minor issue for the category colour option if the settings are using bullet or boxes rather than bars - I only created it for the bars option in the settings and it falls back to grey in the other options. Fixable largely in css I think but haven’t cracked it yet - I will!

3 Likes

Thanks for this great theme @pmusaraj! :raised_hands:

I would like to use the COMMENTS icon but am not a huge fan of the solid version. When I use comments I get the solid version. The solid version is typically served up as “fas fa-comments
What if I would like to use is the regular version which is typically served up as “far fa-comments

Out of the following variations, there are some that require the paid subscription. Is there a way to select different variations or is the solid version the only one available?

3 Likes

I added to my theme, as follows:

how do I now add this to the theme settings? Here’s what I tried to do…

2 Likes

Use “far-comments” in both settings, like this:

The paid versions aren’t publicly available so we can’t include them in Discourse. If their license permits, you can add them in a custom SVG sprite in your theme. Full instructions for that are in the Introducing Font Awesome 5 and SVG icons, read carefully the section “Adding custom icons”.

4 Likes

Thank you for the help with this! Adding far-comments to both areas worked perfectly!

Can you take a quick look at this other question I asked (in response to another one of your comments in this topic)…

1 Like

Hi awesome theme component! I am having trouble adding font awesome or uploads using icons-sprite upload. Can only get question-circle to display. What am I doing wrong? Do I need to add css coding?

Pics below

And

Font awesome names always says not found and create? Have tried direct name and prefix ie bullhorn or fa-bullhorn

Update have font awesome working. Found svg icon in settings to add however it is not using colour setting as with question-circle.

Would like to use custom svg icons but need a noob how to.

1 Like

Looking at the site on your profile, I see icons for categories, so maybe you solved this already? If not, from the screenshot above, I think you need to make sure the SVG file in icons-sprite is an SVG sprite file (not an individual icon). More details in Replace Discourse's default SVG icons with custom icons in a theme

6 Likes