CoolCMS API

UrlTrait

Table of Contents

Methods

buildLinkParams()  : array<string, mixed>
Builds the URL parameters for a link.
getCurrentValue()  : int|null
Returns the current parameter value from the URL.
prepareOptions()  : array<int, array{key: int, label: ?string, icon: ?string, title: ?string, active: bool, url: string}>
Normalizes the options into a uniform format for the template.

Methods

buildLinkParams()

Builds the URL parameters for a link.

private buildLinkParams(string $param, int $value) : array<string, mixed>
Parameters
$param : string
$value : int
Return values
array<string, mixed>

getCurrentValue()

Returns the current parameter value from the URL.

private getCurrentValue(string $param) : int|null
Parameters
$param : string
Return values
int|null

prepareOptions()

Normalizes the options into a uniform format for the template.

private prepareOptions(string $param, array<int, string|int|array{icon: string, title: string}> $options[, int|null $activeValue = null ]) : array<int, array{key: int, label: ?string, icon: ?string, title: ?string, active: bool, url: string}>

Input formats: string: [1 => 'Newest'] -> label int: [1 => 20] -> label (number as text) array: [1 => ['icon' => '...', 'title' => '...']] -> icon + title

Parameters
$param : string
$options : array<int, string|int|array{icon: string, title: string}>
$activeValue : int|null = null

override of the active value: null = read from the URL; a value outside the option keys (e.g. 0) = no choice active

Return values
array<int, array{key: int, label: ?string, icon: ?string, title: ?string, active: bool, url: string}>
On this page

Search results