Caution: This documentation is for eZ Publish legacy, from version 3.x to 6.x.
For 5.x documentation covering Platform see eZ Documentation Center, for difference between legacy and Platform see 5.x Architecture overview.

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"

Balazs Halasy (05/02/2004 11:49 am)

Svitlana Shatokhina (11/08/2006 11:00 am)

Balazs Halasy, Svitlana Shatokhina


Comments

  • Added new parameter

    Added in
    3.6.10 (stable/3.6 (3.6.10) rev. 16513),
    3.7.8 (stable/3.7 rev. 16512),
    3.8.3 (stable/3.8 rev. 16499),
    3.9.0alpha1 (trunk rev. 16500).

    # Added new parameter to ezroot/ezurl:
    # New parameter: "full" or "relative" ("relative" by default)
    # Usage:
    ezroot:
    {"var/cache/images/root.png"|ezroot(,'full')} will produce:
    "http://<hostname>:<port>/var/cache/images/root.png"
    ezurl:
    {"var/cache/images/root.png"|ezurl(,'full')} will produce:
    "http://<hostname>:<port>/<siteaccess>/var/cache/images/root.png"