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 name | Type | Description |
|---|---|---|
| name | string | \eZ\Publish\API\Repository\Values\Content\Location | The name of the route or a Location instance |
| parameters | array | An arrayhash of parameters:
|
| absolute | boolean | Whether to generate an absolute URL |
...
I don't have the Location object
...
Generating a link from a Location ID
| Code Block | ||
|---|---|---|
| ||
<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 | ||||
|---|---|---|---|---|
|
| Status | ||||
|---|---|---|---|---|
|
| Code Block | ||
|---|---|---|
| ||
<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:
- alias is history
- alias is custom with forward flag true
- requested URL is not case-sensitive equal with the one loaded
...