Adding a button to each post



  • Hey, I feel like I'm missing something but is there currently no method to have a plugin add a button to a post?

    partials/topic/post-menu.tpl pulls data from a posts object defined here -- so that's where I guess a filter:posts.build would go, and then we'd add something similar to regFormEntry to the partial.

    It feels sorta inefficient to do that for every single post but I guess that's what needs to be done? Am I missing something somewhere?





  • +1

    would also like to be able to add a configurable button to posts.



  • The loop to add buttons was merged into persona. A similar addition should probably be added to vanilla.

    I now add buttons in my plugin via hook filter:post.getPosts and in the hook:

      Plugin.postsBuild = function(params, cb) {
        var histButton = {action: 'posts/edithistory', icon: 'fa-file-text', html: 'Edit History'};
    
        async.map(params.posts, function(post, next) {
          if(!post) return next();
    
          if(!!post.tools) {
            post.tools = [];
          }
          post.tools.push(histButton);
    
        });
    
        cb(null, params);
      };
    

Log in to reply
 


Looks like your connection to NodeBB was lost, please wait while we try to reconnect.