Skip to content

Kirby 3.9.8

params()

Returns all params from the current Url

params(): array

Return type

array

Examples

Besides with URL query variables, you can set parameters via URL in Kirby in a more human-readable way:

http://yourdomain.com/blog/tag:mytag/year:2014

Note that you have to use a semicolon instead of a colon on Windows systems. In your code, you can use the url() method with the params parameter to make sure that the resulting URL is compatible with both Linux and Windows servers, e.g.

$url = url($path, ['params' => ['tag' => 'myTag']]);

Those parameters are very handy when you want to build URL-based filters for your content.

Such parameters will be ignored by the router so the URL which will be fetched by Kirby in this case is http://yourdomain.com/blog.

The params function returns all detected params:

// http://yourdomain.com/blog/tag:mytag/year:2014
$params = params();

// $params is array('tag' => 'mytag', 'year' => '2014')
// you can also get a single param with the param function.