Add additional button post menu

Hey.
I’m quite new to Discourse plugin making, but I was wondering if anyone could help me explaining how to add additional button to post menu. As far as I can see, this should be handled via custom plugin.
For example, Made you laugh button, that would behave in similar way as Like - storing how many people clicked it on post or comment.
I’m aware of Retort plugin, but it won’t solve the problem for me, as I’m more like interested in understanding how to add this button.

Hi,
this is a tricky one. From my experience, this should go through a plugin. You’ll have to add additional button to post-menu widget, and you’ll have to add a migration to db to store your “made you laugh” reactions.

You could use discourse solved plugin for inspiration:

This plugin also adds additional button to post menu and adds functionality that is stored in db.

Make sure you read the developers guide for building plugins:

Good luck.

3 Likes

Thanks a lot, @zcuric, I’ve tried to get understanding of this plugin, and Retort also, yet no luck so far, but will continue in this direction.
Could you also, please, hint in what way Discourse manages render of Like button? Specifically, how does it hide Like button on your own posts? So I could do the same for my custom button.

@marek You are welcome. You’ll have read the code a bit, starting from here:

Regarding backend it is API request 99%. I didn’t go much into it. Probably an endpoint. My guess is when building a plugin you’ll have to do a REST API routes with GET, POST, DELETE endpoints that will fill the data your field in database which you added by database migration and that will be done with Rails. At least that’s how I would approach the situation.

2 Likes