Parameters replace the bit?wise masking technique used in site components and modules.
The mosParameters class has three methods that you will use to access parameters: get( 'name' [, 'default' )This methods will return the value of a parameter if it exists or is set, otherwise it returns the 'default' value (or an empty string).set( 'name', 'value' )This method method sets the value of a parameter. It returns the value set.def( 'name', 'default' )This method combines both get and set. It will check to see if the parameter of 'name' exists. If it does it returns it. If it doesn't it sets it to 'default' and returns that value.Here are some examples:
A good example of how to use the def method is when you want to use a global state by default, for example, a parameter may be defined like:
Notice that the "Use Global" option is an empty string. You may then have the following code in you module or component:
$hide_author = $params?>def( 'hide_author', $mosConfig_hideauthor );
If the "hide_author" parameter is not defined, that is, it is an empty string or not present at all, then the parameter will be set to the second argument, in this case the global setting for hiding author names, and that value will be returned by the method. If the parameters is not empty, that is, either "0" or "1" then the parameter will not be changed and the actual setting is returned by the method.