Table of Contents

getState

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

Retrieves model state variables.

This method will either return the value of a specified state variable, or will return a reference to the JObject object that is used to store the model’s state variables.

Syntax

mixed getState ( $property )

$property string is the name of the state variable to retrieve. This parameter is optional and if omitted, defaults to null. If null is specified the internal state object is returned which stores all the state variables for the model.

Examples

Example

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

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

$model =& JModel::getInstance( 'hellos', 'HelloModel' );

$model->setState( 'filter', 'value1' );
echo $model->getState( 'filter' )."\n";

$states =& $model->getState();
echo $states->get('filter');

might produce

Result

value1
value1