Back to Pagination class

Method setAdditionalUrlParam

public mixed
setAdditionalUrlParam
(mixed $key, mixed $value)
Method to set an additional URL parameter to be added to all pagination class generated links.
Parameters
  • string $key The name of the URL parameter for which to set a value.
  • mixed $value The value to set for the URL parameter.
Returns
  • mixed The old value for the parameter.
Since
  • 1.6
Class: Pagination
Project: Joomla

Method setAdditionalUrlParam - Source code

/**
 * Method to set an additional URL parameter to be added to all pagination class generated
 * links.
 *
 * @param   string  $key    The name of the URL parameter for which to set a value.
 * @param   mixed   $value  The value to set for the URL parameter.
 *
 * @return  mixed  The old value for the parameter.
 *
 * @since   1.6
 */
public function setAdditionalUrlParam($key, $value)
{
    // Get the old value to return and set the new one for the URL parameter.
    $result = $this->additionalUrlParams[$key] ?? null;
    // If the passed parameter value is null unset the parameter, otherwise set it to the given value.
    if ($value === null) {
        unset($this->additionalUrlParams[$key]);
    } else {
        $this->additionalUrlParams[$key] = $value;
    }
    return $result;
}