Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Table for Options

LincLinc Admin
edited September 2009 in Vanilla 2.0 - 2.8
I've noticed there's no "options" table in the database schema.

If I'm making an addon that has a few options in the dash, where am I supposed to store those settings? Should every addon get a new database table even if it needs nothing more than to store a few values?

Again drawing on my limited Wordpress plugin experience, there's a wp_options table with columns option_name and option_value, which is a flexible way for plugin authors to store simple things like dash settings without adding tables.

Would it be appropriate to create one in the default installation of Vanilla 2 or Garden to encourage a standard way of doing this?

Comments

  • Vanilla 2 works more through storing config values in files, ie. conf/config.php file. There is the configuration manager and a few classes for changing config values.
  • Is there any documentation on it besides what's in /library/core/class.configuration.php?
  • edited September 2009
    At a quick look no, but the best way to learn it would be to see how other apps and plugins do it.

    $Config = Gdn::Factory(Gdn::AliasConfig); $Path = PATH_CONF . DS . 'config.php'; $Config->Load($Path, 'Save'); $Config->Set('Routes'.'.friends/requests', "friendslist/friends/requests"); $Config->Save($Path);

    That may help you. Its some code i was using to change the config file for routes.
  • OK, thanks for the info.
  • MarkMark Vanilla Staff
    Now that you mention it, we should probably have a convenience function to do this...
  • Yes please! :D
  • Aye @Mark that would be handy. It is a bit of a mess at the moment.
  • MarkMark Vanilla Staff
    OK - I just pushed two convenience functions to master and replaced code throughout the application to use the convenience functions. They are SaveToConfig($Name, $Value), and RemoveFromConfig($Name);

    Enjoy :)
  • Thanks @Mark :)
  • MarkMark Vanilla Staff
    Oh, they both take $Name as an associative array (optionally) if you want to save a bunch of stuff at once.
Sign In or Register to comment.