Adding buttons to posts

Plugin Development
  • Hello all!

    I'm trying to add a button to all posts from a plugin. I'd rather do it serverside if possible, and it seems that some kind of support for this did exists at least:

    https://community.nodebb.org/topic/6507/adding-a-button-to-each-post/4

    This doesn't seem to work any more.

    Any pointers on how to do this best? Ideally I'd want another button next to "reply", although adding it to the post dropdown wouldn't be terrible either.

  • I don't see anywhere to add buttons, but the post.tools filter does add things to the dropdown.

    If you ask me though, there should be an additional block and filter there to add buttons. I suggest filter:post.buttons.

  • @yariplus said:

    I suggest filter:post.buttons

    That would be nice.

    Meanwhile, filter:post.tools doesn't seem to get triggered... I may be doing it wrong due to being a noob but I'm doing this:

    "hooks": [
            { "hook": "filter:post.getPosts", "method": "getPosts" },
            { "hook": "filter:post.tools", "method": "buildPostTools" }
        ],
    

    And in JS I just did this so I can inspect the object I get:

    Plugin.buildPostTools = function(data, cb) {
        console.log('building post tools');
        console.log(data);
        
        cb(null, data);
    };
    

    But it's not getting called? getPosts works fine.

    (I'm also probably missing an error object there)

  • @Onyx said:
    It only gets called when you click the dropdown.

  • @yariplus Aaah, I see how that works now. Thanks. Now off to figure the rest out... Out of interest, is there like a Slack chat or IRC or something so I don't spam the forums with noob questions?

  • There is nodebb-plugin-slack, but it looks like it's not been updated in a while and may no longer run on latest nbb. I don't see anything for irc. If your forum isn't huge, putting an iframe of an embedded irc client into an HTML widget may be be doable for you.

  • @yariplus I meant a place to chat and get help, not install it as a plugin on my forum 😛

    Also, I can't find a way to hook into click events on the button. Tried searching through other plugins but I didn't find anything that would demonstrate this. I did see some of the base plugins using action:controller.method syntax but these don't seem to get triggered automatically?

    Sorry for being a bit of a pain but the docs are a bit scarce, and while I'm OK with JavaScript in general my NodeJS knowledge is... lacking, at best, so poking around the source is not something that's very effective in my case.


Suggested Topics