Post Badges

:discourse2: Summary Post Badges will add earned badges next to a post author’s username. Specific badges to display can be adjusted through a theme setting.
:eyeglasses: Preview Preview on theme-creator.discourse.org
:hammer_and_wrench: Repository Link https://github.com/discourse/discourse-post-badges
:open_book: New to Discourse Themes? Beginner’s guide to using Discourse Themes

Install this theme component

Key features

  • Support for both default and custom badges.
  • Hovering over the badge will show a tooltip with the badge’s description.
  • Clicking on the badge will take a user to the badge’s overview page

Usage tips

  • Some default badges contain links in their descriptions. These will not display nicely as a tooltip, so it is recommended to customize the description at /admin/customize/site_texts. You can find what you need to modify by searching for part of the description’s current text.

Settings

Installation

If you are unfamiliar with theme components and how to install them, check out the theme installation guide. And if you’d like to learn more about Discourse themes, take a look at this guide.

67 Likes

You can create custom badges for groups and show them next to the author’s name. If you put the link to the group in the description of the badge you make everything easier.

12 Likes

After using this component for a few days I feel it’s not quite production-ready yet: it’s really hammering my server with lots of requests and slowed down the entire site. Also, on larger topics I saw lots and lots of 429 response codes in the console as it was querying the badges of each individual poster.

I really love the idea here and so does my community, but I think it could use a little more TLC first :slight_smile:

12 Likes

You’re right, thanks for reporting!

The intended behavior was to only make one request per user, per full-page load. This means if you have a topic with 1000 posts and 8 participants, there would be 8 requests max. If you went to another topic (without a full-page load) that had the same 8 participants and 2 new participants, there would only be 2 requests.

I think I’ve have a fix to accomplish the intended behavior, but I need to do some more testing. Stay tuned.

PS - The end goal will be to have 0 requests, but there is a limitation with components that prevents this for now.

17 Likes

Hi @tshenry, is it viable for this change to the badge link to be configurable?

When showing a badge in the topic view, I can already see that a specific user has a specific badge, making the click-through feel redundant. I prefer the previous behavior of clicking through to see all users with a specific badge, as it quickly gives me additional information instead of just a different view of the same user.

Thanks for your work, our community very much enjoys this!

3 Likes

It would be neat if you could do this on a per-link basis by adding an optional parameter to the link (eg. add the parameter → links to the user’s badge page):

6 Likes

I’ve been attempting to move where the post badges display on posts. The approach I’m trying to take is creating a div above the post controls, and popping the css in there but I’m not super great with web design. If anybody has a suggestion on how to do this, I’d very much appreciate it, please and thank you!

1 Like

This is excellent, thank you so much! Would love to be able to have users decide which badges they’d want/not want displayed on an individual level in the future - totally understand if this isn’t feasible though. :smile:

2 Likes

Would be great if feasible. I actually had a user who wanted this very feature. On our old forum we didn’t have that sort of functionality, so I was surprised they even thought of it.

2 Likes

That’s good to know that there’s other interest!

Hi @tshenry, any news about this?

1 Like

Sorry for the delayed response. It was a busy week last week and I didn’t get an opportunity to work on this component.

This is priority #1 regarding this component. Going to do my best to nail down a viable solution, hopefully this week.

Sure, I’ll work on making the badge linking a little more flexible.

This is definitely a more challenging request. I don’t think it can be done with the current limitations. I agree it would be a pretty cool feature, though. Definitely noted, but I’m not sure if/when this will happen.

10 Likes

Alright, I finally have an update :tada: Things should be in a much better place as far as server requests go (@bartv) . I’ve also added a basic setting to choose between the badge overview page and the user’s badge page for the badge links (@FoohonPie). No optional per-badge parameter yet.

Please let me know if you notice any issues. I tried to test things as best as I could, but you never know. The capabilities of themes continue to grow, so hopefully I’ll be able to continue to improve the implementation over time.

11 Likes

I just tried this out and was experiencing some heavy server load, site crashing at times.

Also getting this error in console

1 Like

Thanks for the report! I reverted the request reduction attempt for now as it was causing a different issue. This was one of those lovely “fix one thing, break another” situations. It’s proving quite challenging to get everything perfect.

I was hoping to get something in place by the weekend, but clearly there are still some kinks to work out :pensive:

9 Likes

Appreciate the response and your dedication to getting this working.

Looking forward to your fix.

1 Like

This is an essential component that should be part of the core.

Sometimes the badges show, sometimes they don’t. I haven’t found the rhyme or reason- my best guess is that they don’t show toward the end of longer topics. On refresh, they might show. Apologies if this is re-phrasing the “request reduction” issue listed above.

3 Likes

I appreciate the enthusiasm on the component!

I haven’t gotten a good opportunity to dive back into this, but it’s far from forgotten. I’ll make sure to put some time into it next week.

Edit: I think I’ve made a breakthrough with this. I’m not going to get ahead of myself again, though. I’ll make sure to do a lot of testing next week and update this topic when I have good news.

8 Likes

Alright, let’s give this another shot!

I think I’ve made it as efficient as I can at this point. I tested as many scenarios as I could think of, and it looks to be in much better shape. Please update the component from your admin dashboard and let me know if you run into any issues.

Thank you to everyone for their patience and interest with this component :heart:

13 Likes

Haven’t ran into any problems, however, I do have a suggestion! Maybe a way to display all badges instead of having to list them specifically? I’ve got a setup where people really want to display all badges they have, but I don’t like how messy it is to have to include every badge explicitly. Just an idea!

Maybe something as simple as an asterisk as a wildcard (and this opens up the opportunity to include all custom badges easily by prefixing/suffixing their names and using a wildcard to discern which badges to include).

Great work though! Extremely satisfied that someone did this (and very elegantly too).

2 Likes