A series of methods are offered to make it easy for plugins to set and retrieve options. These options can be directly edited from inside the Nucleus admin area, taking the need away for the plugin to provide an admin area of its own, and avoiding that options need to be set inside the PHP file itself.
Options are available in different contexts:
Several types of options are provided
yes' or the value 'no' (on edit, shown as radio button)Option 1|value1|Option 2|value2|Option 3|value3
As of Nucleus v3.2, some option types can be limited to only accept certain values using option-metadata. This metadata is stored in the $typeExtras-field, and is a semicolon-seperated list of values. Note: In a select-option, the select list must be the first value in $typeExtras.
| key | explanation |
|---|---|
datatype |
Using 'datatype' you can give some extra hints to Nucleus about the datatype you want to use. Currently only 'numerical' is available. 'numerical' will cause Nucleus to only accept numerical values for this option (using both client-side and server-side check) (available for optiontypes: 'select' and 'text') |
access |
If set to 'readonly', the option will not be editable (available for optiontypes: 'text' and 'textarea')If set to ' hidden', the option will be completely hidden for the end-user (available for optiontypes: 'text') |
some examples:
// following code creates a text-option that only accepts numerical values
$this->createBlogOption('FooBar', 'foobar', 'text', '0', 'datatype=numerical');
// following code creates a select-option that only accepts numerical values
$this->createItemOption('FooBar', 'foobar', 'select', '0', '0|0|1|1|2|2;datatype=numerical');
// following code creates a textarea-option that is readonly
$this->createOption('FooBar', 'foobar', 'textarea', 'Textarea is readonly', 'access=readonly');
Creates a new option in the global context
| parameter | value |
|---|---|
| $name | Option name |
| $desc | Textual description, to be shown on the page where options can be edited |
| $type | Option type (see above) |
| $defValue | Initial value |
| $typeExtras | Extra info on option type (see above) |
Creates an option in the blog context (see createOption)
Creates an option in the category context (see createOption)
Creates an option in the member context (see createOption)
Creates an option in the item context (see createOption)
changes the value of an option that was already in the database
| parameter | value |
|---|---|
| $name | Option name |
| $value | New value for option |
Changes the value for a blog option. The blogid attribute indicates for which blog the option is valid. (other options: see setOption)
Changes the value for a category option. The catid attribute indicates for which category the option is valid. (other options: see setOption)
Changes the value for a member option. The memberid attribute indicates for which member the option is valid. (other options: see setOption)
Changes the value for an item option. The itemid attribute indicates for which item the option is valid. (other options: see setOption)
Returns the value for an option in the database
| parameter | value |
|---|---|
| $name | Option name |
Returns the value for a blog option. blogid indicates for which blog a value is requested (other parameters: see getOption)
Returns the value for a category option. catid indicates for which category a value is requested (other parameters: see getOption)
Returns the value for a member option. memberid indicates for which member a value is requested (other parameters: see getOption)
Returns the value for an item option. itemid indicates for which item a value is requested (other parameters: see getOption)
Deletes an option from the database
| parameter | value |
|---|---|
| $name | Option name |
Deletes a blog option (see deleteOption)
Deletes a category option (see deleteOption)
Deletes a member option (see deleteOption)
Deletes an item option (see deleteOption)
Returns all values for a given blog option. The result is an associative array with a value for each existing blogid
Returns all values for a given category option. The result is an associative array with a value for each existing catid
Returns all values for a given member option. The result is an associative array with a value for each existing memberid
Returns all values for a given item option. The result is an associative array with a value for each existing itemid
Returns the top of the values for a given option. The result is an array where every element is an array with a value ('value') for each blogid ('id')
| parameter | value |
|---|---|
| $name | Option name |
| $amount | The amount of options you want |
| $sort | Sort ascending ('asc') or descending ('desc') |
Returns the top of the values for a given option. The result is an array where every element is an array with a value ('value') for each memberid ('id') (parameters: see getBlogOptionTop)
Returns the top of the values for a given option. The result is an array where every element is an array with a value ('value') for each categoryid ('id') (parameters: see getBlogOptionTop)
Returns the top of the values for a given option. The result is an array where every element is an array with a value ('value') for each itemid ('id') (parameters: see getBlogOptionTop)
init() method instead.