Is it possible to override templates?
-
I'd like to make some minor changes to Persona's templates. Is there any guidance available on how best to go about this?
-
Yep, simply creating a template with the same name in a plugin works.
In the plugin.json, tell it where your templates are located, e.g.
"templates": "./templates"
And then if any file name in your plugin's 'templates' directory matches a template name in your theme's 'template' directory, yours will override it.
example,
if
nodebb-plugin-yourplug/templates/categories.tpl
exists,
it will overridenodebb-theme-persona/templates/categories.tpl
You might need to clear your browser cache though, not sure how to fix that.
-
@yariplus that sounds pretty straightforward. My only question is plugin.json, where would I find that file? Is it in /path/to/nodebb/ or must I create a new plugin?
-
The way I did it is with a new plugin. I don't think there's any other way at the moment.
-
@yariplus great, thanks for your help.
-
Keep in mind that because you are overwriting the template provided by the selected theme, if there are updates to that template, you will not receive them.
Just a friendly warning
-
@julian Got ya. Thanks for the heads up