Global navigation

   Documentation Center
   eZ Studio & eZ Platform
     User Manual
     Technical Manual
     Glossary
   eZ Publish 4.x / legacy

 
eZ Publish (5.x)

eZ Publish 5.x | For eZ Platform & eZ Studio topics see Technical manual and User manual, for eZ Publish 4.x and Legacy topics see eZ Publish legacy

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Description

ez_urlalias() is a Twig helper for generating  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

ez_urlaliaspath( eZ\Publish\API\Repository\Values\Content\Location|string name[, array parameters][, bool absolute] )

Argument nameTypeDescription
namestring | \eZ\Publish\API\Repository\Values\Content\Location
The name of the route or a Location instance
parametersarray

An

array

hash of parameters:

  • locationId
  • contentId (as of 5.4 / 2014.11) 
absolutebooleanWhether to generate an absolute URL

...

I don't have the Location object

...

Generating a link from a Location ID

Code Block
languagexml
<a href="{{ path( "ez_urlalias", {"locationId": 123} ) }}">Some link to a location, with its Id only</a>

 The parameter for the second path() argument is the locationId for URLAlias

Generating a link from a Content ID

Link generation from contentId is available as of 

Status
colourYellow
title5.4
 / 
Status
colourYellow
title2014.11
.

Code Block
languagexml
<a href="{{ path( "ez_urlalias", {"contentId": 456} ) }}">Some link from a contentId</a>

 

Important: Links generated from a Content ID will point to its 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

 

...