Come si può aggiungere un pulsante di attivazione/disattivazione al menu dei post e implementare un'azione per quel pulsante di attivazione/disattivazione in un plugin Discourse?

Hi!,
I’m new to Discourse plugin making and would appreciate some help with adding a toggle button to the post menu and implementing its action in the plugin.

Hi @omppatil perhaps this post might help you get in the right direction:

Also if you are new to Discourse plugin programming:

2 Mi Piace

Hi!

You can use addPostMenuButton

api.addPostMenuButton('coffee', () => {
 return {
   action: 'drinkCoffee',
   icon: 'coffee',
   className: 'hot-coffee',
   title: 'coffee.title',
   position: 'first'  // can be `first`, `last` or `second-last-hidden`
 };
});

Then you can add your action this way:

api.attachWidgetAction("post", "drinkCoffee", function () {
    //
}

EDIT: Got Lillian’d :smile:. It would also be a good idea to follow the guides Lilly posted!

3 Mi Piace

Therefore, what file structure should be implemented, and where should the above code be placed?

Reading the above linked topics should answer your related dev questions. It’s possible you could achieve what you want with a theme component instead of plugin. Thus, I would also add these to your reading list:

also, from the first link I posted:

3 Mi Piace

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.