Is it possible to change dropdown names?

Hi community :slight_smile:

Does anyone happen to know if there’s an option to change dropdown names inside a particular category?

I’d love to customize ‘all’ and ‘all tags’ parts:

Pretty much all text can be customised:

I’m guessing you need to edit, for example:

2 Likes

But it won’t change for specific categories only.

Is started working on a very hacky CSS solution, it’s not perfect… And I’m a bit reluctant to share something that hacky anyway. :confounded:

5 Likes

Got it, thank you for your help! @merefield @Canapin

3 Likes

Oh sorry, scan read!

Yes, they are global.

1 Like

Oh go on :wink: :wink:

I think it’s overly complex, especially when subcategories aren’t defined as such in the HTML code… I have a half-working thing, but I think it should be done the right way, and Discourse JS API might help with this. Unfortunately, I don’t know much about it.

5 Likes

Hello :wave:

I’ve made a theme component now to achieve this…

It contains two settings to make it easier.

category name
First Place: category slug
Second Place: category dropdown title

tag name
First Place: category slug
Second Place: tag dropdown title

Which will looks like this.

Adding subcategory Tag title

Screenshot 2023-08-23 at 14.38.40

I hope it helps :slightly_smiling_face:


Edit: I fixed the dropdown width to align correctly to the custom text width. UX: fix the dropdown width to keep the custom content width · VaperinaDEV/category-breadcrumb-dropdown-title@faca71c · GitHub

Screenshot 2023-08-23 at 17.38.21

Screenshot 2023-08-23 at 17.38.53

8 Likes

wow, great work @Don - you amaze me :exploding_head: :star_struck:

2 Likes

Hear ye!
:man_mage:

From the depths of SCSS mysteries and the intricacies of front-end alchemy, Sir Don has arisen. Conquering functions, mastering loops, and decrypting lists, we proudly confer upon him the illustrious Front-End Medal of Distinction :medal_sports::bowing_man:.

And your component works without a single JS line…

Happy James Corden GIF by The Late Late Show with James Corden

1 Like

Please tell me GPT4bot helped you write that :laughing:

4 Likes

100% yes, I’m afraid.

2 Likes

Ok so this solution is impressive, but you can do this @Don:

api
  .modifySelectKit("category-drop")
  .replaceContent((component, content) => {
    let newContent = [];
    content.forEach((item) => {
      if (
        component.category?.slug === "general" &&
        item.id === "all-categories"
      ) {
        item.name = "jojo";
      }

      newContent.push(item);
    });
    return newContent;
  });

Screenshot 2023-08-23 at 18.47.33

https://github.com/discourse/discourse/blob/main/app/assets/javascripts/select-kit/addon/mixins/plugin-api.js lists all the actions you can make:

  • appendContent
  • prependContent
  • replaceContent
  • onChange

Let me know if you have troubles using this. It should probably be better documented, but Im here if you have any question.

6 Likes

@Don @joffreyjaffeux you are absolutely awesome, guys!! :fire:

3 Likes