How can creare new button in topic button

  • GNU/Linux

    I need to create a new button beetween " component="thread/sort"" and thread tools in topic page. I don't know how I can do this. Anyone can suggest some existing plugin or can I do this?

    0_1474624542392_Schermata del 2016-09-23 11:53:06.png

  • Community Rep

    Easiest is some js in the custom header. (Although, if you are making a lot of changes, you really should be using a custom theme.)

    $(window).on('action:ajaxify.contentLoaded', function(){
      $('[component="thread/sort"]').after(' <button class="btn btn-default yourbutton" type="button">Do Something</button>');
        // Do whatever you want.

    (The leading space in the after() is intentional)

  • Althought i think it could be a cleaner approach, if you want the new button as part of plugin functionality you can take a look at nodebb-plugin-ignore-users there i put an icon instead of a button, inserted with client javascript, as @yariplus alreafy suggested, taking in consideration what page is rendered.

    You can see if that approach fits for your purpose on the client.js file of the mentioned plugin. I'm sure there would be better examples on official plugins but can't remember one right now that you can take a look at.

Suggested Topics

| | | |