Blog

Joomla 3.X: Class JRequest is deprecated, how to use JInput instead.

This class serves to provide the Joomla Platform with a common interface to access request variables.
We can easily catch URL variables through the JRequest class and use the results to change or control template output:

$view = JRequest::getVar('view', null);
$option = JRequest::getVar('option', null);

You can everytime know if you are on a blog view and/or which component are active:

echo $view; // Show e.g. "featured" if you are on the Homepage
echo $option; // Show e.g. "com_contact" if you are on a Contact page of the CMS

The class JRequest is now deprecated and we need to use JInput class.
This is an abstracted class used to manage retrieving data from the application environment.
We use the getCmd (get command) method:

Gets a value from the input data.
getCmd(mixed $name, \= $default) : string
Arguments
$name = mixed
$default = ''

Here's an example of how to obtain the same variables through the class JInput:

$app = JFactory::getApplication(); // If not yet defined
$option = $app->input->getCmd('option', '');
$view = $app->input->getCmd('view', '');

Thanks, Fabrizio.

Qui il contenuto ITEM MIDDLE
Qui il contenuto ITEM RIGHT
Qui il contenuto COLUMN RIGHT