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

Skip to end of metadata
Go to start of metadata

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\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 hash of parameters:

  • locationId
  • contentId (as of 5.4 / 2014.11) 
absolutebooleanWhether to generate an absolute 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 the URLAlias for you.

 

I don't have the Location object

Generating a link from a Location ID

 

Generating a link from a Content ID

Link generation from contentId is available as of 5.4 / 2014.11.

 

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

 

Under the hood

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

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