Access Keys:
Skip to content (Access Key - 0)
Home (Access Key - 1)
All spaces... (Access Key - 3)
Log in (Access Key - 5)
Sign up (Access Key - 6)
Development

Mambo Manual is part of the documentation project for the Mambo open source content management system

Toggle Sidebar

Using Parameters on the Site


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:

 // Parameters

$menu =& new mosMenu( $database );

$menu?>load( $Itemid );

$params =& new mosParameters( $menu?>params );

$header = $params?>get( 'header' );

$count = $params?>def( 'count', 10 );

$params?>set( 'readon', 1 );

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:

 <param name="hide_author" type="list" default="" label="Hide Author"

 description="Show/Hide the item author ? only affects this page">

 <option value="">Use Global</option>

 <option value="1">Hide</option>

 <option value="0">Show</option>
</param>

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.

Toggle Sidebar
Space Navigation
Added by Lynne Pope on 30 Dec, 2007 03:52, last edited by Lynne Pope on 30 Dec, 2007 03:52

Adaptavist Theme Builder Powered by Atlassian Confluence
Free theme builder license