ez_urlalias
is a not a real Twig helper, but a special route name for generating URLs for a location, from the given parameters.
path( eZ\Publish\API\Repository\Values\Content\Location|string name[, array parameters][, bool absolute] )
Argument name | Type | Description |
---|---|---|
name | string | \eZ\Publish\API\Repository\Values\Content\Location | The name of the route or a Location instance |
parameters | array | An hash of parameters:
|
absolute | boolean | Whether to generate an absolute URL |
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.
{# Assuming "location" variable is a valid eZ\Publish\API\Repository\Values\Content\Location object #} <a href="{{ path( location ) }}">Some link to a location</a> |
<a href="{{ path( "ez_urlalias", {"locationId": 123} ) }}">Some link to a location, with its Id only</a> |
Link generation from contentId is available as of /
.
<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.
For Location alias setup 301 redirect to Location's current URL when: