Url
Extends Object. Urls give you much more powerful methods over Strings when dealing with URLs for pages or images.
Instantiation
You can create a Url object either of these methods.
<?ev
// url class method
var homepage = new Url('/');
// or, url function method (lowercase)
var homepage = url('/');
?>
Construct parameters |
---|
url
String
A String representing the URL. This may be any external or internal URL including Theme URLs file based paths e.g. ~/content etc. |
Properties |
---|
absolute
String
The absolute URL. If you originally supplied a relative path to the URL object it will automatically detect your current protocol and output the correct HTTP or HTTPS protocol and associated domain. |
hash
String
The hash fragment at the end of the URL. |
hostname
String
The hostname and domain of the URL. If you supplied a relative pathname when instantiating the URL the appropriate hostname for the current protocol will be returned. |
isHttps
Boolean
True if the URL has an HTTPS protocol, else false. |
pathname
String
Path relative to root that follows the domain of the URL. |
port
Number
The port if set. It is very unusual to ever need to utilise ports in Evance themes - we've never needed it yet. |
protocol
String
The current protocol for the URL (e.g. http or https) |
relative
String
The the relative URL and the default representation of URLs. If you supplied a relative URL there's no change here unless you did some transformations. However if you supplied a Theme URL then you will notice that this value miraculously transforms to a proper relative URL. |
search
String
The full query string of the URL. |
Methods |
---|
param(String:key [, String:value])
String
| Url
Get or set a query string parameter.
|
parameter(String:key [, String:value])
String
| Url
Alias of |
params([Object:params])
Object
| Url
Get or set all query parameters.
|
parameters([Object:params])
Object
| Url
Alias of |
toCdn()
Url
Convert a valid static file path based URL to an Evance CDN URL. CDN URLs do not have a protocol, which means they can be used either over HTTP or HTTPS protocols. It is worth noting that <ev:img>, <ev:css> and <ev:js>tags automatically convert relative paths and Theme URLs to CDN URLs for you and you do not need to convert them manually. You may need to use toCdn() only if you are using URLs outside of such tags.
CDN URLs in your CSS
|
toGlobal()
Url
Convert a localised URL with a locale prefix to a globalised version without the locale prefix.
|
toHttp()
Url
Converting toHttp() will convert a URL to the preferred domain for your account that's relevant to the HTTP protocol.
|
toHttps()
Url
Converting toHttps() will convert the URL to the correct domain for HTTPS connections on your account. If you do not have a premium SSL for your own domain the URL will be converted to your Evance account URL.
|
toLocal([locale])
Url
This is useful for multi-lingual or multi-national sites and prefixes the URL with the current locale identifier.
You may also supply a
|
toRedirectString()
String
Converts the relative URL to a redirect compatible String. Evance does not permit external redirects. A good example of usage is with Account Login. Let's say you have a product page and wish trade customers to login to see prices:
|