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

URL handling

This part of the 4.x documentation is for eZ Publish 4.0, only reference section is common for all eZ Publish 4.x versions as well as eZ Publish 5.x "LegacyStack", please select the version you are using for the most up to date documentation!

Whenever a link, a non-content specific image, a stylesheet, etc. is to be included, a suitable template operator must be used in order to ensure that the path to the included file is correct. At any time, one of the following operators should be used:

ezurl

The "ezurl" operator makes sure that a URL works regardless of the location of the eZ Publish folder, the access method and the environment that eZ Publish is running in (non virtual host, virtual host, etc.). It is only the eZ Publish specific part of the URL that needs to be provided. The rest (http://, host, domain, directory, siteaccess, port, etc.) will be generated by the operator. The final output will be a valid address. This approach makes it possible to use generic URLs in template without the risk of having to modify every address when the site is moved and/or when the access method is changed. By default, the "ezurl" operator outputs an address that is already encapsulated by two double quotes. In other words, the output can be fed directly to an hyperlink reference in the HTML code. The following examples demonstrate the usage of this operator.

Link to a module/view (using a system URL)

<a href={'/user/login'|ezurl()}>Login</a>

The example above demonstrates how to create a link to the login view of the user module. The "/user/login" is just an example, another example would be a link to a node: "/content/view/full/34". If eZ Publish is running in a directory called "ezpublish" on www.example.com using the URL access method and the name of the siteaccess is "my_company", the operator will produce the following output:

"http://www.example.com/ezpublish/index.php/my_company/user/login"

If eZ Publish is running in a virtual host mode and uses the host access method, the following URL will be produced:

"http://www.example.com/user/login"

Link to a node (using the node's virtual URL)

When a link to a node (using the node's virtual URL, also known as URL alias) is created, the address must be piped through the "ezurl" operator. The reason for this is that the internal URL table only contains the eZ Publish specific part of the URLs. The following example demonstrates how to use the "ezurl" operator to create a valid virtual URL for a node.

<a href={$node.url_alias|ezurl()}>Link to a node</a>

If the URL alias of the node is "company/about_us" and eZ Publish is running in a virtual host environment using the host access method, the following URL will be produced:

"http://www.example.com/company/about_us"

For information about how eZ Publish treats URLs, please refer to the "URL translation" section of the "Concepts and basics" chapter.

ezimage

The "ezimage" operator works in the same way as the "ezurl" operator (described above), except that it does not include the "index.php" part. This operator must be used every time a non content specific image is included in a template. The image must be placed in the "images" directory of one of the designs that are used by the siteaccess. The operator produces a valid link to the image regardless of the directory, access method and/or the environment that eZ Publish is running in. The following example demonstrates how the "ezimage" operator should be used.

<img src={'women.jpg'|ezimage()} alt="This is my image." ... />

If eZ Publish is using the host access method and the siteaccess is using a design called "my_design", the operator will produce the following output:

"http://www.example.com/design/my_design/images/women.jpg"

If the image is placed inside a sub-directory within the "images" directory, the name of the subdirectory must be specified in the template. If the requested file is not found within the main design of the siteaccess, the system will search for it in the additional designs and the standard design. Please refer to the documentation of the automatic fallback system for more information about this feature.

ezdesign

The "ezdesign" operator works in the same way as the "ezurl" operator (described above), except that it does not include the "index.php" part. This operator must be used every time a design element (style sheets, JavaScript, etc.) is included in a template. The operator takes care of producing a valid link for the given design component by providing the root to the design directory which contains the target file. The following example demonstrates the proper way of including a CSS file using this operator.

...
<style type="text/css">
    @import url({'stylesheets/my_stuff.css'|ezdesign()});
</style>
...

If eZ Publish is using the host access method and the siteaccess is using a design called "my_design", the operator will produce the following output:

"http://www.example.com/design/my_design/stylesheets/my_stuff.css"

If the requested file is not found within the main design of the siteaccess, the system will search for it in the additional designs and the standard design. Please refer to the documentation of the automatic fallback system for more information about this feature.

Balazs Halasy (03/03/2005 9:28 am)

Ricardo Correia (17/04/2013 1:26 pm)

Balazs Halasy, Julia Shymova, Geir Arne Waaler, Ricardo Correia


Comments

  • image references in CSS files

    I think image references in CSS files (e.g. "background-image: url(etc)") entail different considerations.

    On the one hand, you don't need to worry that you can't use ezimage() inside a CSS file, because since URLs in CSS files are relative to the file's location, you can just use "url(../images/etc.gif)" to get to the images directory from your stylesheets directory.

    On the other hand, this means that the URL is hard-coded -- if there's no etc.gif in the main design, the fallback designs won't be checked for it. It will simply get a 404.
  • maually i have installed ezpublish, but having some path problem

    hi
    all,

    images are not displaying in my site
    i want to set the path of an image where can i find the file to which i need to set the path

    regard's
    anantha
  • where to set the image path or where can i define image path of my own template

    Hi
    all,

    I want check the image path ( becuase image is not displaying ).In which file the image path is located..please let me know

    here is my email-id:

    anantha@netcolib.com.
    Please reply ...

    any solution you are most welcome.