November 15, 2011
Many packages use the Config table of the database if there are only a few package wide settings. There is a class to interface to it and more info in the documentation.
http://www.concrete5.org/documentation/developers/system/config-preference-data/
Any add-on can use the config table for storing/retrieving the settings.
Save
$pkg = Package::getByHandle('my_package_handle');
$pkg->saveConfig('MY_CONFIG_SYMBOL', $data );
Retrieve
$pkg = Package::getByHandle('my_package_handle');
$data = $pkg->config('MY_CONFIG_SYMBOL');
The usual convention is that config symbols are upper-case, but this is not set in stone.
Php serialize/unserialize or json can be used to store more complex data structures in config.
Clear
If you want to completely erase a config symbol/value:
$pkg->clearConfig('MY_CONFIG_SYMBOL');
Loading Conversation
Related Tutorials
- 6
- 0
December 04, 2011
- 4
- 0
March 12, 2014
- 4
- 0
July 16, 2013
- 15
- 0
October 26, 2011
- 8
- 0
November 17, 2011
- 14
- 0
August 16, 2010
- 11
- 0
December 04, 2012
- 5
- 0
August 31, 2012
- 7
- 0
February 03, 2014
- 6
- 0
November 07, 2011
- 21
- 0
August 11, 2010
- 6
- 0
February 17, 2013
- 21
- 0
January 26, 2013
- 4
- 0
October 29, 2013
- 13
- 0
March 07, 2011
- 8
- 0
March 30, 2012
- 2
- 0
March 12, 2014
- 17
- 0
January 10, 2011
- 9
- 0
August 09, 2012
- 9
- 0
November 20, 2011