====== Plugins parameters ====== ===== Saving a parameter ===== First, you need to select the //namespace// associated to the parameters with the ''setNameSpace()'' function: $core->blog->settings->setNameSpace('example'); The setNamespace() argument should only contain letters (without accents) or numbers. Allowed characters are [a-zA-Z][a-zA-Z0-9] Use the ''put()'' function to save a parameter. Its arguments are: - the parameter name (a string containing alphanumeric characters or underscore ''_'') - its value - its type (optional) - its label (optional) - wheter to overwrite the previous value or not (optional) (default value is true) - where the parameter is global or not (optional) (default value is false) ==== Example with a string and a label ==== # we set the namespace $core->blog->settings->setNameSpace('example'); # we save the parameter $core->blog->settings->put('example',__('Hello World!'),'string','My label'); # we go back to the default namespace $core->blog->settings->setNameSpace('system'); ==== Parameters types ==== Saving a float: $core->blog->settings->put('float',415618155.5181,'float'); Saving an integer: $core->blog->settings->put('integer',21767426,'integer'); Saving a boolean: $core->blog->settings->put('bool',true,'boolean'); Saving a string: $core->blog->settings->put('string',__('Hello World!'),'string'); To store a string containing more than one line, you should use the ''[[http://fr.php.net/manual/fr/function.base64-encode.php|base64_encode()]]'' function when saving, and the ''[[http://fr.php.net/manual/fr/function.base64-decode.php|base64_decode()]]'' when reading the parameter. This will prevent line break when editing the parameter with [[:2.0:admin:aboutconfig|about:config]]. ===== Reading a parameter ===== A parameter is associated to the $core->blog->settings->**parameter name** variable, for example : $string = $core->blog->settings->string; ===== Deleting a parameter ===== You have to use the ''drop()'' function : $core->blog->settings->setNameSpace('example'); $core->blog->settings->drop('example');