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 aposts
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?
-
here's a PR to take care of it--
https://github.com/NodeBB/nodebb-theme-persona/pull/158
https://github.com/NodeBB/NodeBB/pull/3604 -
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); };