@rahmon IMPORT is actually a NodeBB directive, benchpress doesn't handle imports.
Saving settings to v2 in my template file
-
This saves the settings for my plugin in v1 (config document)
https://github.com/Jenkler/nodebb-plugin-postlink/blob/master/templates/admin/postlink.tpl
But I would like to save settings so its uptodate with latest standards. I guess settings:postlink should be the correct one in my case. I want to have minimal code and everyting in the template file.
Ist there any settings.prepare func for the newer settings framework.
@yariplus any tips?
To get the data I think i will use meta.settings.get. Can I use meta.settings.set in the tpl file?
Is there no default plugin settings in nodeBB
https://github.com/NodeBB/NodeBB/blob/master/public/src/admin/settings.js -
@Jenkler Quickstart is set up to use settings v2 by default:
https://github.com/NodeBB/nodebb-plugin-quickstart/blob/master/static/lib/admin.js
-
Yes but i still need admin.js in my plugin folder. V1 works without any extra files at all. So i guess Nodebb core has no code for default plugin settings as v1 has.
<script>
require(['admin/settings'], function(Settings) {
Settings.prepare();
});
</script>There is no admin/plugin-settings by default.
-
Can you tell me more about what you mean when you say "default plugin settings"?
-
hi, I mean someting like
<script>
require(['admin/settingsplugin'], function(Settings) {
Settings.prepare('pluginname');
});
</script>A default save system as with admin/settings but for plugin data save from the acp. the setting.prepare is nice but only works for config. it would have been nice to have plugin ssve as as core function of nodebb.
There may be many ways todo this but i hope you understand what I mean
or... maybe the same
Settings.prepare('config') and Settings.prepare() saves to config ... and
Settings.prepare('pluginname') saves to the plugin document and not config document.Improve the feat of Settings.prepare hehe
-
@Jenkler You want something like this:
Is that it? Some defaults configs if the user does not want/know to customize them on ACP?
-
It is more complicated, but you don't need a separate file. Most of my plugins use something like this:
<script> require(['settings'], function (settings) { settings.sync('pluginname', $('form')) $('#save').click(function(event) { settings.persist('pluginname', $('form')) }) }) </script>
You need to make a settings object in your init. As well as use the
data-key=name
property in your inputs. -
@yariplus any simple plugin of yours that use this on github so I can sneek peak
Thanks for this solution.
-
sync and persist is v3 @yariplus , no?
Anyways, quickstart uses v2, which is .save() and .load(), in admin.js.
-
@julian oh, dang. you're right. That's the only one I've ever used.
@Jenkler rainbows uses it.
https://github.com/yariplus/nodebb-plugin-rainbows/blob/master/public/templates/admin/plugins/rainbows.tpl#L144-L154
https://github.com/yariplus/nodebb-plugin-rainbows/blob/master/library.js#L61-L72 -
Thanks, i will take a look at it and howl if I get stuck