PAID - Request - add CSS class containing tag group

Update: Adjust the specs to rather use group IDs instead of group names as we often rename those.

See feature request topic here for reference: Request - add CSS class containing tag group - #7 by loginerror

Basically we need tag group CSS classes to be added to each tag so we can hide specific tags and adjust the order the tags are displayed in.

Example:

Tag name; indoor
tag group IDs which the tag is placed in: 1, 12

Current html output:

<a href="/tag/indoor" data-tag-name="indoor" class="discourse-tag box">...

Desired html output:

<a href="/tag/indoor" data-tag-group="location" data-tag-name="indoor" class="discourse-tag box tag-group-1 tag-group-12">...
6 Likes

Updated the requirements to use tag group IDs instead of names since we often rename those

I wouldn’t know how to implement it properly, but would love to see someone pick it up :slight_smile: For reference I had posted a feature request here as well: Add a data-tag-group attribute for tags

As mentioned there I believe the technical implementation would be more aligned with Discourse defaults if it wouldn’t be assigned a class but a data attribute as classes are usually applied for common styles, not for unique identifiers. Also, tags already have the data-tag-name attribute, so a data-tag-group attribute seems to fit right in.

For styling in CSS, there’s no advantage to have a class. It’s just as straightforward to declare styles based on the attribute ([data-tag-group: "group-name"]).

With respect to the id, I believe it’s actually the same as the name. See https://meta.discourse.org/tags.json

For a tag yes, for a tag group no

image

1 Like

Thank you @RGJ !

Also, don’t want to hijack your marketplace topic @jrgong, so please flag or move to my feature request if you think it is!

But I’d still believe if this is also to be generally adopted, it would be both more descriptive and aligned with common attribute naming to use the actual name. So on the tag element it would look like:

data-tag-name="how-to" data-tag-group="documentation"

rather than:

data-tag-name="how-to" data-tag-group="17"

Totally agree with that! Thx for the input :heart:
My idea is to make it accessible for the whole community.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.