How the hell do I get the settings for the plugin
-
const meta = module.parent.require('./meta');
console.log(meta.settings.get('nodebb-widget-rss'));This does not work at all. As I understand it
meta.config is NodeBB configuration and some plugin data. But I am looking for the widget settings.
I cant figure out how to use meta.settings.get
@yariplus @julian @PitaJ Do you have the time to explain this? I am pulling my hair right now
or is there a v3 way now that is better?
-
Check out the following examples:
Edit: Widget settings are passed into the widget render function I think
-
-
Yeah, i know I can get them from render. But i need them in static app load.
-
Do you know if I can get the widget data from meta.settings ?
-
Widget settings aren't available through
meta.settings
. Because you can have:- multiple templates with the same widget
- multiple widget areas per template
- multiple instances of the same widget per widget area
What are you trying to accomplish?
-
let test = meta.settings.get('nodebb-widget-rss', (err, data) => { if (err) { callback(err); return; }});
console.log(test);Tried this, no data.
I am running function that runs itself in some intervall and need to be able to get updated widget settings if it changes in the acp without restarting nodebb.
I know i can get it from render but then it will be dependent on a user visiting the page where the widget is. There must be a way to fetch widget settings at startup and in runtime.
-
@Jenkler like I said, you have to consider a condition where there are multiple instances of the same widget. If you want settings to be shared across widgets, then you'll want to set up an ACP plugin settings page for your widget, and configure global settings there.
-
You could get the widget settings the same way the admin page does. Make a list of widget areas, then fetch the data for each widget. Then, filter the returned object for the specific widget you're looking for.
-
@pitaj did I understand correctly.
Nodebb-plugin use meta.settings.get
Nodebb-widget-* does not have support for meta.settings.getNodebb config global is stored in meta.config.* and should only be used for nodebb core? Old plugin used meta.config.* but that the where a prefix on the key value so we know what config is for what plugin
I still use meta.config.* for settings for everything. I only have global configs for my widgets and plugins.
What is the preferred way and why?
Will meta.config.* be deprecated ? -
Widgets are just a special kind of plugin. You can use meta.settings.get in widgets if you want, but only if you have a setting that is shared across all widget instances.
I'm not sure what you mean by using meta.config but I don't see anything wrong with it.