omppatil
(Om Patil)
Novembre 28, 2023, 12:34
1
Salut !
Je suis nouveau dans la création de plugins Discourse et j’apprécierais un peu d’aide pour ajouter un bouton bascule au menu des publications et implémenter son action dans le plugin.
Lilly
(Lillian Louis)
Novembre 28, 2023, 12:41
2
Salut @omppatil , peut-être que ce post pourrait vous aider à aller dans la bonne direction :
If you want to add a button to the post menu then you’ll need something a little bit different since posts are widgets .
You would need to add something like this to your theme / plugin.
api.addPostMenuButton("my-button", () => {
return {
action: "someAction",
icon: "someIcon",
className: "someClass",
title: "some title",
};
});
The plugin API has a method for adding new buttons that makes this relatively easy.
https://github.com/discourse/discourse/blob/7a2e8d3ead63c7d99e…
Aussi, si vous êtes nouveau dans la programmation de plugins Discourse :
I’ve only just started but here’s my ‘starter for 10’ to get you going:
Read:
these
this
Try and read the code on the simplest, but popular plugins and see if you can understand what they are doing (this is not always easy, especially with the complexity of dealing with multiple files and the sometimes brutal functional brevity of javasctipt, but persevere)
You need to learn:
Lots of Javascript (look no further than @mpj ’s Fun Fun Function excellent & fun (!) videos (thanks man!))
Lots of …
There are a few ‘how to start’ guides for working with Discourse already and a wealth of useful info on meta, but I thought it might help to give an insight to the mental processes of starting from little, if any, prior coding experience to building substantial Discourse plugins.
Discourse is written by experienced developers and has a large codebase. This can feel intimidating. This intimidation factor can be a significant barrier for novice developers. This is a kind of ‘psychological primer’…
2 « J'aime »
Salut !
Vous pouvez utiliser addPostMenuButton
api.addPostMenuButton('coffee', () => {
return {
action: 'drinkCoffee',
icon: 'coffee',
className: 'hot-coffee',
title: 'coffee.title',
position: 'first' // peut être `first`, `last` ou `second-last-hidden`
};
});
Ensuite, vous pouvez ajouter votre action de cette façon :
api.attachWidgetAction("post", "drinkCoffee", function () {
//
}
EDIT : J’ai été “Lillianisé” . Ce serait également une bonne idée de suivre les guides que Lilly a publiés !
3 « J'aime »
omppatil
(Om Patil)
Novembre 28, 2023, 12:53
4
Par conséquent, quelle structure de fichiers doit être mise en œuvre et où le code ci-dessus doit-il être placé ?
Lilly
(Lillian Louis)
Novembre 28, 2023, 1:26
5
La lecture des sujets liés ci-dessus devrait répondre à vos questions de développement connexes. Il est possible que vous puissiez réaliser ce que vous souhaitez avec un composant de thème au lieu d’un plugin. Par conséquent, j’ajouterais également ceci à votre liste de lecture :
This is a crash course in Discourse theme basics. The target audience is everyone who is not familiar with Discourse themes. If you’ve already used Discourse theme / theme components, this guide is probably not something you need to read.
What are themes and theme components?
A theme or theme component is a set of files packaged together designed to either modify Discourse visually or to add new features.
Let’s start with themes.
Themes
In general, themes are not supposed to be compatible …
Discourse Themes and Theme Components can be used to customize the look, feel and functionality of Discourse’s frontend. This section of the developer guides aims to provide all the reference materials you need to develop simple themes for a single site, right up to complex open-source theme components.
This introduction aims to provide a map of all the tools and APIs for theme development. If you prefer a step-by-step tutorial for theme development, jump straight to:
Themes vs. Theme Compon…
également, à partir du premier lien que j’ai posté :
Joe:
Ce composant de thème utilise cette méthode pour ajouter un nouveau bouton à ce menu en fonction de certaines conditions et définit une nouvelle action, alors jetez un œil ici
https://github.com/discourse/raw-post-button
3 « J'aime »
system
(system)
A fermé ce sujet ()
Décembre 28, 2023, 1:26
6
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.