Request

Extends Object. A "request" variable containing a Request object is automatically instantiated on all pages.

Properties
back

Type String

The absolute url to the HTTP REFERER or 'javascript:history.back(1);' if there is no referrer. 

isHttps

Type Boolean

True if the URL has an HTTPS protocol, else false.

path

Type String

The relative URL of the current page excluding the query string.

referrer

Type URL

URL object of the referrer url if it exists.



Methods
belongsTo([Array:urls])

Returns Boolean

Checks whether the current url is, or is a child of, the supplied url or array of urls.


<?ev
    // the current url is /shop/category
    
    print(request.belongsTo('/shop');
    // true
    
    print(request.belongsTo(['/a', '/b']));
    // false
?>
param(String:key [, String:default])

Returns String | Object

Get a query string parameter from the current URL.


<?ev
    // the current url is /shop/category?a=123&b=456
    
    print(request.param('a'));
    // 123
    
    print(request.param('c', false));
    // false
?>
parameter(String:key [, String:default])

Alias of Request.param().

parameters([Array:exclusions])

Returns Object

Get all query string parameters.


<?ev
    // the current url is /shop/category?a=123&b=456
    
    print(request.parameters);
    // { a: 123, b: 456 }
?>

You can exclude returned parameters by passing through either a string or an array.


<?ev
    print(request.parameters('b'));
    // { a: 123 }
    
    print(request.parameters(['a', 'b']));
    // no results
?>
uri([Object:parameters])

Returns Url

Get the full url of the current page including the query string.


<?ev
    // the current url is /shop/category?a=123
    
    print(request.uri);
    // /shop/category?a=123
?>

You can also append or modify query string parameters to the uri by passing through an associative array of parameters.


<?ev
    print(request.uri({ b: 456 }));
    // /shop/category?a=123&b=456
    
    print(request.uri({ a: 321 }));
    // /shop/category?a=321
?>