Customize new topic button text

Install this theme component

Features

This theme component allows you to customize the New Topic button on a category or tag topic list as well as the action name and button in the composer (highlighted below). If you have a bug category, for example, you can update these texts to say “Report Bug”:

(Some icons may need to be added to your svg icon subset admin setting)

You can also customize the reply button text, this will replace the reply text in the composer and within topics:

Screenshot 2024-01-05 at 4.56.35 PM

Settings

Name Description
custom new topic text This is where you enter the details for each customized button
inherit parent category When disabled, subcategories will not automatically inherit the parent category text

There are two settings, the primary being custom new topic text:

This setting allows you to set the filter (tag or category name), the icon for the “New Topic” button (this doesn’t change the icons in the composer), as well as the action name at the top of the composer, and the composer’s “Create Topic” button.

There’s an additional setting, enabled by default, called inherit parent category. When this is enabled all child categories will also have their text changed (unless otherwise specified in the settings).

:information_source: Note that if you set up a tag it will override the selected category.

:bulb: Ideas for future enhancements

  • Localizable text for different languages
  • Support for category and tag combinations, and multiple tags

:discourse2: Hosted by us? Theme components are available to use on our Standard, Business, and Enterprise plans.

Last edited by @JammyDodger 2024-06-11T22:21:54Z

Check documentPerform check on document:
25 Likes

Tha’ts really good, Thanks alot <3

Today, I was working on a much simpler version of this using api.customizeComposerText() :sweat_smile:

This is a so much better solution. Thank you @awesomerobot!

In my experiments, I was never able to override the Composer button label for the categories using the discourse-post-voting plugin. This becomes a bigger issue when multiple categories are enabled for post voting.

If I may suggest; enabling support for overriding discourse-post-voting labels, would be a great enhancement. ( :

1 Like

This is a great theme component! An idea to take it a step further could be this:

If you are renaming the button because you effectively want to change what the type of topic is, then you should change the naming throughout the entire *category.

For example:
You have a category called Events. You would effectively change the word “topic” in the entire category to “events”. It’s not “New Topic” its “New Event”, instead of a Topics list you’d have an Events list, etc.

You see this in other tools where you change the primary use case of something. Here is what AirTable does when you create a new table. Tables, by default, have “records”.
image

But let’s say I want to create a table called “Users”, then I can change each record to be called Users:
image

Treating the theme component this way would allow us to easily, effectively rebrand a category as a more specific entity. Support Requests, Events, etc.

I found this theme component when searching, because I wanted to change this word for “Topic” to “Events”:

3 Likes

@awesomerobot this theme component is seriously incredible, thank you so much for it!

I’m noticing that this theme component seems to cause some odd behavior with the css for the New Topic button.

Theme component disabled:

Theme component enabled:


I’ve also noticed that while it changes the “Create Topic” button in the composer, which is awesome…

It also changes the Reply button text to that same string, which is less than ideal because it’s not creating another bug report, it’s a reply :slight_smile:

What are the chances another field could be added to the editor to change the reply button text (or leave it blank to leave it as Reply?

4 Likes

Sorry, one last thing: this also does not seem to respect the case where two subcategories (each of a different parent) have the same slug. e.g.:

  • parent1
    • sub1
  • parent2
    • sub1

In this case, I cannot get the theme component to differentiate between the two subcategories, and they both share the same configuration from the editor.

3 Likes

Thanks for the feedback, I’ve made some updates! FIX: action, switch category to ID, ignore replies by awesomerobot · Pull Request #5 · discourse/discourse-customize-new-topic-button-text · GitHub

I completely overlooked the reply button! For now I’ve just kept it as reply, but a separate setting to change its text would make sense.

Good point, it seems like utilizing the category ID rather than the category name in the settings would be the best way to avoid this. So this means any existing settings you have in place will need to be updated.

3 Likes

It seems there’s a new bug. When this plugin is enabled, it creates two topic buttons:

2 Likes

Yes, thanks for reporting it, some connectors changed in Discourse — should be fixed now if you update:

2 Likes

Is it possible to fix the button size difference? (old screenshot, your newest update fixed the double-button issue)

1 Like

Yes, this button should be the correct height now

1 Like
Hmm attempting to use this component unsuccessfully and seeing a lot of warnings in my logs like this one.

Message (4 copies reported)

[DiscourseJsProcessor] DEPRECATION: Using {{attrs}} to reference named arguments has been deprecated. {{attrs.canCreateTopic}} should be updated to {{@canCreateTopic}}. (‘discourse/components/custom-new-topic-button.hbs’ @ L2:C8) [deprecation id: attrs-arg-access] See Ember.js - Deprecations for more details.
at theme-transpiler.js:3164:26752
at j. (theme-transpiler.js:3168:1693)
at theme-transpiler.js:3168:161
at j. (theme-transpiler.js:3168:1693)
at D (theme-transpiler.js:3168:1754)
at te (theme-transpiler.js:3168:1318)
at PathExpression (theme-transpiler.js:3198:21763)
at yo (theme-transpiler.js:3187:2776)
at Al (theme-transpiler.js:3187:3513)
at Ml (theme-transpiler.js:3187:3309)
at yo (theme-transpiler.js:3187:3013)
at Al (theme-transpiler.js:3187:3513)
at Ml (theme-transpiler.js:3187:3309)
at yo (theme-transpiler.js:3187:3013)
at Ml (theme-transpiler.js:3187:3350)
at yo (theme-transpiler.js:3187:3013)
at Al (theme-transpiler.js:3187:3513)
at Ml (theme-transpiler.js:3187:3309)
at yo (theme-transpiler.js:3187:3013)
at Bi (theme-transpiler.js:3187:3879)
at PA (theme-transpiler.js:3190:3002)
at Cf (theme-transpiler.js:3190:9856)
at Al (theme-transpiler.js:3176:35353)
at gf (theme-transpiler.js:3176:35600)
at D (theme-transpiler.js:3198:42250)
at Sft.o.precompile (theme-transpiler.js:3281:3078)
at dDe (theme-transpiler.js:3161:1003)
at e.CallExpression (theme-transpiler.js:3159:33796)
at h (theme-transpiler.js:10:111797)
at e.uPe [as _call] (theme-transpiler.js:59:16906)
at e.oPe [as call] (theme-transpiler.js:59:16726)
at e.lPe [as visit] (theme-transpiler.js:59:17700)
at t.visitQueue (theme-transpiler.js:59:40645)
at t.visitSingle (theme-tr…

Backtrace

/var/www/discourse/lib/discourse_js_processor.rb:133:in block in create_new_context' mini_racer-0.8.0/lib/mini_racer.rb:273:in block in attach’
mini_racer-0.8.0/lib/mini_racer.rb:242:in call_unsafe' mini_racer-0.8.0/lib/mini_racer.rb:242:in block (2 levels) in call’
mini_racer-0.8.0/lib/mini_racer.rb:369:in timeout' mini_racer-0.8.0/lib/mini_racer.rb:241:in block in call’
mini_racer-0.8.0/lib/mini_racer.rb:240:in synchronize' mini_racer-0.8.0/lib/mini_racer.rb:240:in call’
/var/www/discourse/lib/discourse_js_processor.rb:168:in block in v8_call' /var/www/discourse/lib/discourse_js_processor.rb:167:in synchronize’

1 Like

Hmm strange, I tested it on the latest Discourse and everything’s working fine — I’ve just merged an update to the component that will solve that deprecation issue, can you update and try again?

1 Like

Same here, its not showing up after multiple trys.

Unfortunately, this wonderful theme component does not seem to work along nicely with Custom Wizard Plugin 🧙

The Wizard plugin is able to hook to the category button via Category settings:

When using your Component, the button changes it’s name, but pressing it no longer launches Wizard selected in the category settings. We would be glad to use your component in big production website, but unable now. Hope it could be fixed. No pressure :slight_smile:

I’m not seeing this, I have the same setup and my buttons work. You may need to look at other plugins or TC’s. I’m on the latest builds FYI.

1 Like

This is a nice little component that can add some nice attention-to-detail polish to a site.

1 Like

Hello

I think I have a bug.

The text of the “New Topic” button can no longer be modified.
The modification is effective for the other buttons.

Version: 3.2.0.beta4-dev([4886c1fddc]

Thank you for your help (and for these functions!)

2 Likes

Thanks for the report!

It looks like there is a regression from the latest PR:

It converts from the this.args.<param>. to @<param> syntax; however, the former is required since we are inside a plugin outlet.

EDIT: I made a PR :+1:

1 Like

Thanks for the PR @Arkshine! this should be fixed on update

This will also be included on update: FEATURE: add ability to customize "Reply" text by 3-w-c · Pull Request #7 · discourse/discourse-customize-new-topic-button-text · GitHub

So now the option to also customize the reply button text in the composer and on posts (still based on tag and category) will be included.

1 Like