eZ Publish 5.1+ comes with a Twig helper as a global variable named
This helper is accessible from all Twig templates and allows you to easily retrieve useful information.
Returns the current siteaccess.
|Returns the requested URI string (also known as semanticPathInfo).|
|Returns the "system" URI string. System URI is the URI for internal content controller. If current route is not an URLAlias, then the current Pathinfo is returned.|
|Returns the view parameters as a hash.|
|Returns the view parameters as a string.|
|Returns legacy information.|
ezpublish.legacy property returns an object of type ParameterBag, which is a container for key/value pairs, and contains additional properties to retrieve/handle legacy information.
|Returns all the parameters, with all the contained information.|
|Returns the parameter keys only.|
|Returns a parameter by name.|
|Returns true if the parameter is defined.|
Listing the available parameters
You can list the available parameters in
ezpublish.legacy by using the
ezpublish.legacy.keys property, as shown in the following example:
which will give a result similar to:
Retrieving legacy information
Legacy information is accessible by using the
ezpublish.legacy.get property, which will allow you to access all data contained in $module_result, from the legacy kernel.
This allows you to import information directly into twig templates. For more details please check the available examples on using the
ezpublish.legacy.get property for retrieving persistent variables and assets.
As a usage example, if you want to access the legacy information related to 'content_info' you can do it, as shown in the following example:
The previous call will return the contents on the 'content_info' as an
array, and if we
dump it the result will be similar to the following:
Additionally, for retrieving information contained in 'content_info' such as the current language of the content in the page you can do it like in the following example: