Skip to the content
Documentation

URL handling

No ratings yet

Never write the address of a page, an image or a stylesheet into a template as it is. An installation can run in a subfolder, with the siteaccess in the address, behind index.php, or on its own host, and a design file can come from any design of the chain. Four operators build the right address for the request:

Operator For Looks in
ezurl pages: nodes, module views the site's address, with the siteaccess and index.php where needed
ezimage images of the design (not content images) images/ of each design of the chain
ezdesign stylesheets, scripts and other design files each design of the chain
ezroot files at a fixed path of the installation the installation's root folder

By default each operator puts double quotes around its result, so it goes straight into an attribute, without quotes of your own.

ezurl

<a href={$node.url_alias|ezurl}>{$node.name|wash}</a>
<a href={'user/login'|ezurl}>Sign in</a>
<a href={concat( 'content/view/full/', $node.node_id )|ezurl}>...</a>

For a node, use its url_alias, the address editors see; the system address content/​view/​full/​<node id> works too. For a module view, give the module and view: user/login, content/search. On a siteaccess with its own host, {'user/​login'|ezurl} prints "/user/login"; when the siteaccess is part of the address, or the installation runs in a subfolder or through index.php, those parts are added in front.

ezurl takes two parameters:

Parameter Values
quote 'double' (the default), 'single', or 'no' for no quotes, for example in a value you pass on
server_url 'relative' (the default), or 'full' for the address with scheme and host, for mails and feeds
{def $link = $node.url_alias|ezurl( 'no', 'full' )}
<a href="{$link}">{$link|wash}</a>
{undef $link}

An absolute address, such as a link an editor entered, is left as it is and escaped for the attribute when it is quoted. URL aliases and how addresses are translated are described in URL translation.

ezimage

ezimage finds an image below images/ of the design chain: the first design that has the file wins.

<img src={'logo.png'|ezimage} alt="My company" />
<img src={'icons/search.svg'|ezimage} alt="" />

Images that are content, uploaded by editors, are shown with attribute_view_gui and the image aliases of image.ini, never with ezimage (see Outputting node and object data).

ezdesign

ezdesign finds any file in the design chain, by its path below the design folder:

<link rel="stylesheet" href={'stylesheets/site.css'|ezdesign} />
<script src={'javascript/site.js'|ezdesign}></script>

The result is the path of the design where the file was found, for example "/​extension/​mytheme/​design/​example/​stylesheets/​site.​css". For stylesheets and scripts the ezjscore operators ezcss_load and ezscript_load are usually the better choice, because they can pack the files; see The pagelayout.

ezroot

ezroot prefixes a path with the installation's root, for files that are not in the design chain:

<link rel="icon" href={'design/standard/images/favicon.ico'|ezroot} />

Every parameter of the four operators: ezurl, ezimage, ezdesign, ezroot.

Contributors

Comments (3 historical)

Written by readers of the earlier documentation sites, kept as they were.

  1. image references in CSS files

    Linus ·

    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.

  2. maually i have installed exponential, but having some path problem

    anantha ·

    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

  3. where to set the image path or where can i define image path of my own template

    anantha ·

    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:
    [email protected].
    Please reply ...
    any solution you are most welcome.

Comments

Add a comment

Comments are read by a moderator before they appear.