Be invited in podcasts
Be visible on nodejs community
Hey Nodebb Team:
Is it possible to write a plugin to override templates in nodebb-widget-essentials instead of fork a new one?
Thanks,
Ethan
Sure thing, any template you define with the same name and path will override a previously loaded one.
Thanks, but how could I control the order when the plugin is loaded?
@yariplus said in Override templates in nodebb-widget-essentials:
Sure thing, any template you define with the same name and path will override a previously loaded one.
@ethanwu In the ACP plugins menu, there is a button on the right that says "Order Active Plugins". Make sure your plugin is below widget-essentials.
@yariplus said in Override templates in nodebb-widget-essentials:
@ethanwu In the ACP plugins menu, there is a button on the right that says "Order Active Plugins". Make sure your plugin is below widget-essentials.
Thanks, I did that. And the console also prints "/widgets/categories.tpl replaced by {my-plugin}".
However, after I restart the server, the templates still remaining unchanged. Is there anything wrong?
Oh, sorry about that. Looks like widget-essentials still uses some old code that reads the raw template file without looking for replacements. I'll see if I can get this fixed for you.
@yariplus said in Override templates in nodebb-widget-essentials:
Oh, sorry about that. Looks like widget-essentials still uses some old code that reads the raw template file without looking for replacements. I'll see if I can get this fixed for you.
Thanks, can you let me know how. I would love to help on this.
I looked at the plugin, in the init
method, it seem it directly load from the __dirname
https://github.com/NodeBB/nodebb-widget-essentials/blob/master/library.js#L44
Do you know what should i change to enable it to read from the overridden one?
Thanks,
Ethan
@ethanwu I just submitted the changes needed here.
If you want to use it right away, you can just replace the widget-essentials library.js
file with mine until it is updated.
@yariplus said in Override templates in nodebb-widget-essentials:
@ethanwu I just submitted the changes needed here.
If you want to use it right away, you can just replace the widget-essentials
library.js
file with mine until it is updated.
Thanks, i will test it today.