Support Joomla!

references:joomla.framework:application:jmodel-setstate

Table of Contents

setState

API Package Subpackage Class Method Reference Last reviewed Doc status
API Home Package Joomla.Framework Subpackage Application Class JModel Method setState Reference setState() Never Work in Progress

Sets model state variables.

Model state variables can be used to pass information from the controller to the view and to the model. These values can later be retrieved using JModel::getState().

This method returns the value that is assign to the state variable.

Syntax

mixed setState ( $property, $value )

$property string is a string containing the name of the property to set.
$value mixed is a variable containing the value to set to the specified property. This parameter is optional and if omitted defaults to null.

Examples

Example

jimport( 'joomla.application.component.model' );

class PollModelPoll extends JModel
{
	function __construct() {
		$config = array(
			'table_path' => JPATH_COMPONENT.DS.'tables'
		);
		parent::__construct( $config );
	}
}

$model =& JModel::getInstance( 'poll', 'PollModel' );

$model->setState( 'filter', 'value1' );
echo $model->getState( 'filter' );

might produce

Result

value1

 
references/joomla.framework/application/jmodel-setstate.txt (684 views) · Last modified: 2007/08/15 14:49