Ka Extensions for OpenCart 4

This documentation applies to Ka Extensions for OpenCart 4.x only. It is not compatible with OpenCart 3.

UrlParams
in component

This is a service class for storing url parameters and building URLs.

Example:

// define available page parameters // $params = array( 'path' => '', 'letters' => '', // letter 'sort' => 'name', 'order' => 'ASC', 'page' => '1', ); $url_params = new UrlParams($this->request, $params); $params = $url_params->getParams(); ... 'href' => $this->url->link('product/category', $url_params->getUrl(['path' => $path])) ... $pagination->url = $this->url->link('product/category', $url_params->getUrl(['page' => '{page}']));

Table of Contents

Properties

Methods

__construct()  : mixed
Reads page parameters listed in the defaults from the request GET.
getParam()  : mixed
Returns a parameter value or its default.
getParams()  : array<string|int, mixed>
Returns parameters merged with defaults and optional overrides.
getUrl()  : string
Returns URL parameters joined by '&'. Parameters can be extended or overwritten; a null value removes the parameter.
getUrlSort()  : string
Returns a URL query string for sorting by a field. The order is toggled when the field is already sorted.
updateParams()  : mixed
Merges new values into the current parameters.
buildParams()  : string
Builds a query string from parameters; the result is cached.

Properties

Methods

__construct()

Reads page parameters listed in the defaults from the request GET.

public __construct(mixed $request, mixed $default_params[, mixed $keep_original = false ]) : mixed

$request — OpenCart request object. $default_params — parameter => default value pairs. $keep_original — do not trim values.

Parameters
$request : mixed
$default_params : mixed
$keep_original : mixed = false

getParam()

Returns a parameter value or its default.

public getParam(mixed $name) : mixed

$name — parameter name.

Parameters
$name : mixed
Return values
mixed —

Value or null.

getParams()

Returns parameters merged with defaults and optional overrides.

public getParams([mixed $arg_params = null ]) : array<string|int, mixed>

$arg_params — parameters overriding the result.

Parameters
$arg_params : mixed = null
Return values
array<string|int, mixed> —

Parameters.

getUrl()

Returns URL parameters joined by '&'. Parameters can be extended or overwritten; a null value removes the parameter.

public getUrl([mixed $params = null ]) : string

$params — parameters to add or override.

Parameters
$params : mixed = null
Return values
string —

Query string.

getUrlSort()

Returns a URL query string for sorting by a field. The order is toggled when the field is already sorted.

public getUrlSort(mixed $field) : string

$field — sort field.

Parameters
$field : mixed
Return values
string —

Query string.

updateParams()

Merges new values into the current parameters.

public updateParams(mixed $params) : mixed

$params — parameters to update.

Parameters
$params : mixed

buildParams()

Builds a query string from parameters; the result is cached.

protected buildParams(mixed $params) : string

$params — parameters.

Parameters
$params : mixed
Return values
string —

Query string.


        
On this page

Search results