• Home
  • Categories
  • Recent
  • Popular
  • Top
  • Tags
  • Users
  • Groups
  • Documentation
    • Home
    • Read API
    • Write API
    • Plugin Development
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
v3.5.1 Latest
Buy Hosting

Saving settings to v2 in my template file

Scheduled Pinned Locked Moved NodeBB Development
11 Posts 4 Posters 664 Views
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • julianJ Offline
    julianJ Offline
    julian GNU/Linux
    replied to Mikael Jenkler on last edited by julian
    #2

    @Jenkler Quickstart is set up to use settings v2 by default:

    https://github.com/NodeBB/nodebb-plugin-quickstart/blob/master/static/lib/admin.js 😄

    1 Reply Last reply
    0
  • JenklerJ Offline
    JenklerJ Offline
    Mikael Jenkler Swedes
    wrote on last edited by Jenkler
    #3

    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.

    1 Reply Last reply
    0
  • julianJ Offline
    julianJ Offline
    julian GNU/Linux
    wrote on last edited by
    #4

    Can you tell me more about what you mean when you say "default plugin settings"?

    1 Reply Last reply
    0
  • JenklerJ Offline
    JenklerJ Offline
    Mikael Jenkler Swedes
    wrote on last edited by Jenkler
    #5

    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

    1 Reply Last reply
    0
  • jtsimoesJ Offline
    jtsimoesJ Offline
    jtsimoes GNU/Linux
    wrote on last edited by
    #6

    @Jenkler You want something like this:

    2e45d04d-ac43-46b1-8e99-424eabe8cab3-image.png

    Is that it? Some defaults configs if the user does not want/know to customize them on ACP?

    1 Reply Last reply
    0
  • yariplusY Offline
    yariplusY Offline
    yariplus Community Rep
    wrote on last edited by
    #7

    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.

    1 Reply Last reply
    0
  • JenklerJ Offline
    JenklerJ Offline
    Mikael Jenkler Swedes
    wrote on last edited by Jenkler
    #8

    @yariplus any simple plugin of yours that use this on github so I can sneek peak 😛 Thanks for this solution.

    1 Reply Last reply
    0
  • julianJ Offline
    julianJ Offline
    julian GNU/Linux
    wrote on last edited by
    #9

    sync and persist is v3 @yariplus , no?

    Anyways, quickstart uses v2, which is .save() and .load(), in admin.js.

    yariplusY 1 Reply Last reply
    0
  • yariplusY Offline
    yariplusY Offline
    yariplus Community Rep
    replied to julian on last edited by
    #10

    @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

    1 Reply Last reply
    0
  • JenklerJ Offline
    JenklerJ Offline
    Mikael Jenkler Swedes
    wrote on last edited by
    #11

    Thanks, i will take a look at it and howl if I get stuck 😛

    1 Reply Last reply
    0

Copyright © 2023 NodeBB | Contributors
  • Login

  • Don't have an account? Register

  • Login or register to search.
Powered by NodeBB Contributors
  • First post
    Last post
0
  • Home
  • Categories
  • Recent
  • Popular
  • Top
  • Tags
  • Users
  • Groups
  • Documentation
    • Home
    • Read API
    • Write API
    • Plugin Development