Message-ID: <272162856.3818.1485855459765.JavaMail.confluence@ip-10-127-227-164> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_3817_1510319622.1485855459761" ------=_Part_3817_1510319622.1485855459761 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Location: file:///C:/exported.html ez_urlalias

ez_urlalias

=20
=20
=20
=20

Description

ez_urlalias is a not a real Twig helper, but a special route name for generating URLs for a Location from the given parameters.

Prototype and Arguments

path(  eZ\Publish\API\Repository\Values\Cont= ent\Location|string name[, array parameters][, bool absolute]  = )

Argument name Type Description
name string | \eZ\Publish\API\Repo= sitory\Values\Content\Location
The name of the route or a Lo= cation instance
parameters array

An hash of parameters:

  • locationId
  • contentId (as of 5.4 / 2014.11)  =
absolute boolean Whether to generate an absolu= te URL

Working with Location

Linking to other Locations is fairly easy and is done with native path() Twig helper (or url() if you want to generate absolute URLs). You just = have to pass it the Location object and path() will generate t= he URLAlias for you.

=20
{# Assuming "location" variable is a valid eZ\Publish\API\Repositor=
y\Values\Content\Location object #}
<a href=3D"{{ path( location ) }}">Some link to a location</a>

=20

 

I don't have the Locatio= n object

Generating a link fro= m a Location ID
=20
<a href=3D"{{ path( "ez_urlalias", {"locationId": 123} ) }}">=
Some link to a location, with its Id only</a>

=20

 

Generating a link from= a Content ID
=20
<a href=3D"{{ path( "ez_urlalias", {"contentId": 456} ) }}">S=
ome link from a contentId</a>
=20

 

Important: Links generated from a Content ID will point to it= s main location.

Error management

For Location alias setup 301 redirect to Location's current URL when:

  1. alias is history
  2. alias is custom with forward flag true
  3. requested URL is not case-sensitive equal with the one loaded

Under the hood

In the backend, path() uses the Router to generate links.

This makes it also easy to generate links from PHP, via the router= service.

=20
=20
=20
=20

=20
=20
=20
------=_Part_3817_1510319622.1485855459761--