I want to change some basic html in a plugin I am experimenting with (would be convenient to have all changes in a single plugin). This would be html that I would put in the header section of the theme customizer on the admin dashboard, if I were using that dashboard instead of a plugin.
In a theme, you would have just a direct folder labeled common, that would have the different files, such as header.html.
I know common stylesheets for a plugin can go in plugin/assets/stylesheets/common. Where would I put this header.html file in a plugin?
For CSS, the equivalent in a plugin is [plugin]/assets/stylesheets/common/[file.scss]
Matching this format, Iâve tried adding a file at [plugin]/assets/views/layouts/common/header.html, but it didnât work (just doing views/header.html didnât work either).
I can change the templates, but for simple html changes like we do in themes a simple html change in header.html (or the equivalent) would be nice. For example, where would you put the following in a plugin (thatâs already doing complex server side stuff, hence the need for a plugin):
I find the differences in how to do stuff like that in a plugin vs in a theme confusing too. You could punt and use a theme component for that stuff, but it sounds like youâre looking for the best answer rather than the fast one. (though there are some advantages to having that stuff split out for separate maintenance)
I think you need to add a line to the plugin.rb that includes the file you want. What I do is clone a thing from the discourse github repo called all-the-plugins and grep there for an example.
Cool. Thanks. Yes, Iâve been thinking that perhaps the situation is that indeed there is not currently a straightforward way to do html changes in a plugin like you would do in a themeâto make html changes you have to go into the templates/connectors in a plugin (not too complicated, but different than the simpler theme mindset of common/header.html).
Iâll take a look at plugin.rb and see if that is currently easier than just going the normal template/component route.
Itâs not where I said, but you stick it in the assets tree with the right name. Itâs impossible to understand until you get it and then itâs totally obvious.
Edit : Hey @JQ331. I just realized that I think I did what you want in s plugin yesterday, but Iâm so bad at it I didnât realize thatâs what youâre looking for. See https://github.com/literatecomputing/discourse-max-topics-per-month. Itâs very simple so thereâs not much to get in the way of finding the example.