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

  • Layout

    A parameter to specify which layout we want to use would be very nice. Because, if you are in layout/set/popup, any links used with the ezurl operator will ouput something like : layout/set/popup/my_link.
    You sometimes need to get back to the default layout.
    • Re: Layout

      Note: you can use the UseAccessPass=false parameter in layout.ini to have the urls from the current layount point back to the 'main' one
  • SiteURL ini settings

    FYI: the host name displaied by all operators of the ezurl family when run in "full" mode do not take into account the SiteURL parameter in the [SiteSettings] section of site.ini - it will instead be based on $_SERVER['HTTP_HOST']
  • How to pass params as variable?

    In the following sample, the first URL is unexpectedly relative. Why? How to dynamise full/relative selection?

    {def $type='full'}
    {''|ezurl('no',$type)}
    {undef $type}
    <br/>
    {''|ezurl('no','full')}

    • Re: How to pass params as variable?

      This is because ezurl() result is "hard coded" in compiled template. So ezurl() can't be contextualy dynamic.