JApplication/getUserStateFromRequest: Difference between revisions
From Joomla! Documentation
m clean up |
m preparing for archive only |
||
| Line 63: | Line 63: | ||
===Examples=== | ===Examples=== | ||
=== Code Examples === | |||
<dpl> | <dpl> | ||
noresultsheader=\n | noresultsheader=\n | ||
category=getUserStateFromRequest | category=getUserStateFromRequest | ||
category=JApplication | category=JApplication | ||
namespace=CodeExample | |||
category=MethodExample | category=MethodExample | ||
include=* | include=* | ||
Latest revision as of 01:18, 25 March 2017
Description
Gets the value of a user state variable.
<! removed transcluded page call, red link never existed >
Syntax
getUserStateFromRequest($key, $request, $default=null, $type= 'none')
| Parameter Name | Default Value | Description |
|---|---|---|
| $key | The key of the user state variable. | |
| $request | The name of the variable passed in a request. | |
| $default | null | The default value for the variable if not found. Optional. |
| $type | 'none' | Filter for the variable, for valid values see . Optional. |
Returns
The request user state.
Defined in
libraries/joomla/application/application.php
Importing
jimport( 'joomla.application.application' );
Source Body
public function getUserStateFromRequest($key, $request, $default = null, $type = 'none')
{
$old_state = $this->getUserState($key);
$cur_state = (!is_null($old_state)) ? $old_state : $default;
$new_state = JRequest::getVar($request, null, 'default', $type);
// Save the new value only if it was set in this request.
if ($new_state !== null) {
$this->setUserState($key, $new_state);
} else {
$new_state = $cur_state;
}
return $new_state;
}
<! removed transcluded page call, red link never existed >
Examples
Code Examples