URL

If your current browser URL is "https://example.se/om-oss/historia". Then to root is "https://example.se/" and URI is "/om-oss/historia".

Se usage examples bellow using the above URL (ROOT+URI).

Get root URL
<?php echo $this->modal()->url()->root(); ?>

Result: https://example.se

Get full URL
<?php echo $this->modal()->url()->url(); ?>

Result: https://example.se/om-oss/historia

Get full URL but only part "Page" from active "ROUTE"
<?php echo $this->modal()->url()->select("page")->url(); ?>

Result: https://example.se/om-oss/historia

Get full URI
<?php echo $this->modal()->url()->uri(); ?>

Result: /om-oss/historia

Get current URI parameter
<?php echo $this->modal()->url()->current(); ?>

Result: historia

Get part of current URI parameter

IF THE URI IS: "/news/id-12"

<?php echo $this->modal()->url()->current("-"); ?>

Result: 12

If you have for example a router like this is "p-\d+", then you can easly get the id by searching for the char seperator

Prepend to URI and return full URL
<?php echo $this->modal()->url()->prepend(["test", "test2"])->url(); ?>

Result: https://example.se/test/test2/om-oss/historia

Append to URI and return full URL
<?php echo $this->modal()->url()->append(["test", "test2"])->url(); ?>

Result: https://example.se/om-oss/historia/test/test2

Working with parmeter array

Prepend and append works like above.

Append to URI and return full URL
<?php print_r($this->modal()->url()->get()); ?>

Result: Array ([page] => Array ( [0] => om-oss [1] => historia))

Append to URI and return full URL
<?php print_r($this->modal()->url()->select("page")->get()); ?>

Result: Array ([0] => om-oss [1] => historia)

Complete function list

Get root URL
@param array/string $add array: ['test', 'test2'] = /test/test2, string: '?js=1'
@return string
root($add = false)
Get current full URL
@return string
url($add = NULL, $append = true)
Get current URI
@return string
uri($add = NULL)
DEPRECATED: Get current parameter (not modifyable)
USE INSTEAD: $this->modal()->url()->select("page")->current()
@example url()->param()->get() // Return alla parameters (ARRAY)
@example url()->param("page")->get() // Return current parameter (STRING)
@param boolean/string $key get all or specify key
@return self
param($key = false)
DEPRECATED: Get part of parameters (not modifyable)
USE INSTEAD: $this->modal()->url()->select("page")->get()
@example url()->part("page")->get() // Return alla "PAGE" parameters (ARRAY)
@param string $key select parameter key
@return self
part($key)
Is used to cusomize selected parameters/URI
@param string/array $type param key
@return self
select($type)
Find position in active param
@param string $posType
@return self
find($posType)
Query out param result, you should not need to use this outside of class. Use methods from \request\url insted.
@param NULL/array $arr reset param array
@return string
query($arr = NULL)
Whitelist include only specified array parameters
@example uri is "/param1/param2/param3"
include(["param1", "param3"])
uri is "/param1/param3"
@param arrray $incl items that should be allowed to be included
@return self
include(array $incl)
Whitelist exclude specified array parameters
@example uri is "/param1/param2/param3"
exclude(["param1", "param3"])
uri is "/param2"
@param arrray $excl items that should be excluded
@return self
exclude(array $excl)
Remove last parameter item
@return self
pop()
Remove first parameter item
@return self
shift()
Remove first parameter item
@return self
remove($index)