ezurl

Summary

Returns a working version of an eZ Publish URL (provided as input).

Usage

input|ezurl( [ quote [, type ] ] )

Parameters

NameTypeDescriptionRequired
quote string Quote style: "no", "single" or "double" (default). No.
type string URL type: "full" or "relative" (default). No.

Returns

A quoted string containing a valid / working version of the input URL.

Description

This operator takes an eZ Publish URL as input (either a system URL or a virtual URL); based on the location of the eZ Publish folder, the access settings and the environment, it will produce a valid address. All eZ Publish URLs that are specified in templates should always be piped through this operator; it will make sure that the URLs work regardless where eZ Publish is installed, which access method is used, and so on.

By default, this operator returns a relative URL as a double-quoted string. The optional "quote" parameter can be used to control the way the address is returned: "no" (no quotes), "single" (single quotes) or "double" (double quotes, the default). The optional "type" parameter controls whether relative or full URL is returned.

Examples

Example 1

Let's say that we're running a site called "my_company" (name of the siteaccess) and that we wish to create a link to the full view of node number 1024. Instead of specifying the entire URL (domain and all included) in the link tag, we pipe "/content/view/full/1024" or the virtual URL (for example "/test") through the "ezurl" operator:

<a href={'/content/view/full/1024'|ezurl(,'full')}>Test</a>
<a href={'/test'|ezurl(,'full')}>Test</a>

The operator will take care of translating the URLs into valid addresses depending on the setup and the environment eZ Publish is running in. If eZ Publish is running in a virtual host environment and uses the host access method, the following type of URLs will be produced:

"http://www.example.com/content/view/full/1024"
"http://www.example.com/test"

The "index.php" part of the URL will be supressed by the virtual host configuration. The name of the siteaccess will not appear in the URL because eZ Publish will use the domain/host to figure out which siteaccess to use.

If eZ Publish is running in a non-virtual host environment and uses the uri access method, the following URLs will be produced:

"http://www.example.com/index.php/my_company/content/view/full/1024"
"http://www.example.com/index.php/my_company/test"

Example 2

<a href={'/content/view/full/1024'|ezurl()}>Test</a>
<a href={'/test'|ezurl()}>Test</a>

If eZ Publish is running in a virtual host environment and uses the host access method, the following type of URLs will be produced:

"/content/view/full/1024"
"/test"

The "index.php" part of the URL will be supressed by the virtual host configuration. The name of the siteaccess will not appear in the URL because eZ Publish will use the domain/host to figure out which siteaccess to use.

If eZ Publish is running in a non-virtual host environment and uses the uri access method, the following URLs will be produced:

"/index.php/my_company/content/view/full/1024"
"/index.php/my_company/test"

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2013 eZ Systems AS (except where otherwise noted). All rights reserved.