- Theme Engine
- Design Principles
- Templates
- EVML Reference
- Output
- Comments
- Operators
- Statements and Declarations
- Built-in Functions
- Built-in Objects
- Account
- Address
- Array
- Boolean
- Branch
- Cart
- CartLine
- Category
- CategoryCollection
- CategoryFilter
- CategoryFilterCollection
- CategoryFilterOption
- CategorySearch
- Collection
- Color
- Contact
- Currency
- Date
- Discount
- Dom
- Event
- EventCollection
- EventSlot
- Image
- Layout
- Locale
- Money
- Number
- Object
- Page
- PageCollection
- PageSearch
- PageSharer
- Pagination
- Postage
- Price
- PriceDiscount
- Product
- ProductCollection
- ProductCustomisation
- ProductDownload
- ProductMedia
- ProductMediaFrame
- ProductPrice
- ProductSearch
- ProductSpecification
- ProductSpecificationValue
- ProductVariation
- ProductVariationOption
- RecentlyViewed
- RegExp
- Request
- Review
- ReviewCollection
- Search
- SearchCollection
- SearchResult
- String
- Tag
- Template
- Url
- Website
- EV Tags
- CSS Pre-processor
- Ajax API
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 |
Type 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 |
Type 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 |
Type String The hash fragment at the end of the URL. |
hostname |
Type 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 |
Type Boolean True if the URL has an HTTPS protocol, else false. |
pathname |
Type String Path relative to root that follows the domain of the URL. |
port |
Type 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 |
Type String The current protocol for the URL (e.g. http or https) |
relative |
Type 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 |
Type String The full query string of the URL. |
Methods | |
---|---|
param(String:key [, String:value])
|
Get or set a query string parameter.
|
parameter(String:key [, String:value]) |
Alias of |
params([Object:params]) |
Get or set all query parameters.
|
parameters([Object:params]) |
Alias of |
toCdn() |
Returns 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() |
Returns Url Convert a localised URL with a locale prefix to a globalised version without the locale prefix.
|
toHttp() |
Returns Url Converting toHttp() will convert a URL to the preferred domain for your account that's relevant to the HTTP protocol.
|
toHttps() |
Returns 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]) |
Returns 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() |
Returns 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:
|