You should pass to $urlparams
an array where the keys are variable names and values are the corresponding filters of this variables. For example:
$urlparams = array(
'catid' => 'INT',
'id' => 'INT',
'cid' => 'ARRAY',
'year' => 'INT',
'month' => 'INT',
'limit' => 'UINT',
'limitstart' => 'UINT',
'showall' => 'INT',
'return' => 'BASE64',
'filter' => 'STRING',
'filter_order' => 'CMD',
'filter_order_Dir' => 'CMD',
'filter-search' => 'STRING',
'print' => 'BOOLEAN',
'lang' => 'CMD',
'Itemid' => 'INT'
);
This array is used to build the cache in the parent controller's display()
method:
/libraries/legacy/controller/legacy.php
// Display the view
if ($cachable && $viewType != 'feed' && $conf->get('caching') >= 1)
{
$option = $this->input->get('option');
$cache = JFactory::getCache($option, 'view');
if (is_array($urlparams))
{
$app = JFactory::getApplication();
if (!empty($app->registeredurlparams))
{
$registeredurlparams = $app->registeredurlparams;
}
else
{
$registeredurlparams = new stdClass;
}
foreach ($urlparams as $key => $value)
{
// Add your safe url parameters with variable type as value {@see JFilterInput::clean()}.
$registeredurlparams->$key = $value;
}
$app->registeredurlparams = $registeredurlparams;
}
$cache->get($view, 'display');
}
else
{
$view->display();
}
As you can see it is used for $app->registeredurlparams
which is used in the JCache
class to make the unique id of the cache in the makeId()
method:
/libraries/joomla/cache/cache.php
/**
* Create safe id for cached data from url parameters set by plugins and framework
*
* @return string md5 encoded cacheid
*
* @since 11.1
*/
public static function makeId()
{
$app = JFactory::getApplication();
$registeredurlparams = new stdClass;
// Get url parameters set by plugins
if (!empty($app->registeredurlparams))
{
$registeredurlparams = $app->registeredurlparams;
}
// Platform defaults
$defaulturlparams = array(
'format' => 'WORD',
'option' => 'WORD',
'view' => 'WORD',
'layout' => 'WORD',
'tpl' => 'CMD',
'id' => 'INT'
);
// Use platform defaults if parameter doesn't already exist.
foreach ($defaulturlparams as $param => $type)
{
if (!property_exists($registeredurlparams, $param))
{
$registeredurlparams->$param = $type;
}
}
$safeuriaddon = new stdClass;
foreach ($registeredurlparams as $key => $value)
{
$safeuriaddon->$key = $app->input->get($key, null, $value);
}
return md5(serialize($safeuriaddon));
}
This great article will explain more about Joomla cache.