Want to add button to top right of topic view

(Thomas Smyth) #1


Currently this is just a hard coded {{view …}} in the topic template. How should I go about adding a plugin hook for this? The existing plugin hooks use this.trigger inside a ContainerView class. Should I create one that does nothing except provide a hook for plugins, and then put that in the template? Or perhaps for cases like this there should be a generic ContainerView that takes the name of the plugin hook as an argument?

Thoughts? Thanks.

(Régis Hanol) #2

Next week, I’ll add support to overwrite any handlebars template from a plugin. This should make it easier for you to add that button.

(Jeff Atwood) #3

Can’t this be done with a JavaScript customization now? @techapj can you add an example here, ala Bitnami?

(Arpit Jalan) #4

Yes, we now have a plugin-outlet to add a button to the top right of topic view – topic-title

Here is the JS code you are looking for:

  var ApplicationRoute = require('discourse/routes/application').default;
    actions: {
      customAction: function() {
        // your code here
        console.log("it works!");

<script type='text/x-handlebars' data-template-name='/connectors/topic-title/custom-button'>
  {{#if currentUser}}
    {{d-button id="custom-button" class="btn-default" action="customAction" icon="plus" label="topic.create"}}

Add custom CSS:

.custom-button {
  // custom style

This will add a button at the top right of topic view:

You may also want to look at this topic:

(Jeff Atwood) #5

Hmm that is good, but what about a button here? Perhaps there is another topic that is more appropriate?


Sorry for “revive this topic”

I think this is the topic:

(Erlend Sogge Heggen) closed #7