| API | Package | Subpackage | Class | Method | Reference | Last reviewed | Doc status |
|---|---|---|---|---|---|---|---|
Home |
Joomla.Framework |
Application |
JModel |
getState |
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.
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. |
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