eZ Publish 5 comes with a Twig helper as a global variable named ezpublish.

This helper is accessible from all Twig templates and allows you to easily retrieve useful information.

Reference

PropertyDescription
ezpublish.siteaccess

Returns the current siteaccess.

ezpublish.requestedUriStringReturns the requested URI string (also known as semanticPathInfo).
ezpublish.systemUriStringReturns 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.
ezpublish.viewParametersReturns the view parameters as a hash.
ezpublish.viewParametersStringReturns the view parameters as a string.
ezpublish.siteNameReturns the name of the current siteaccess.
ezpublish.legacyReturns legacy information.

 

Legacy

The 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.

PropertyDescription
ezpublish.legacy.allReturns all the parameters, with all the contained information.
ezpublish.legacy.keysReturns the parameter keys only.
ezpublish.legacy.replaceReplaces the current parameters by a new set.
ezpublish.legacy.addAdds parameters.
ezpublish.legacy.getReturns a parameter by name.
ezpublish.legacy.setSets a parameter by name.
ezpublish.legacy.hasReturns true if the parameter is defined.
ezpublish.legacy.removeRemoves a parameter.
ezpublish.legacy.getAlphaReturns the alphabetic characters of the parameter value.
ezpublish.legacy.getAlnumReturns the alphabetic characters and digits of the parameter value.
ezpublish.legacy.getDigitsReturns the digits of the parameter value.
ezpublish.legacy.getIntReturns the parameter value converted to integer.

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:

{{ dump(ezpublish.legacy.keys()) }}

which will return:

array
  0 => string 'view_parameters' (length=15)
  1 => string 'path' (length=4)
  2 => string 'title_path' (length=10)
  3 => string 'section_id' (length=10)
  4 => string 'node_id' (length=7)
  5 => string 'navigation_part' (length=15)
  6 => string 'content_info' (length=12)
  7 => string 'template_list' (length=13)
  8 => string 'cache_ttl' (length=9)
  9 => string 'is_default_navigation_part' (length=26)
  10 => string 'css_files' (length=9)
  11 => string 'js_files' (length=8)
  12 => string 'css_files_configured' (length=20)
  13 => string 'js_files_configured' (length=19)

Retrieving legacy information

Legacy information is accessible by using the ezpublish.legacy.get property.

For example, if you want to access the legacy information related to content_info you can do it, as shown in the following example:

{{ ezpublish.legacy.get('content_info') }}

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:

array
  'object_id' => string '57' (length=2)
  'node_id' => string '2' (length=1)
  'parent_node_id' => string '1' (length=1)
  'class_id' => string '23' (length=2)
  'class_identifier' => string 'landing_page' (length=12)
  'remote_id' => string '8a9c9c761004866fb458d89910f52bee' (length=32)
  'node_remote_id' => string 'f3e90596361e31d496d4026eb624c983' (length=32)
  'offset' => boolean false
  'viewmode' => string 'full' (length=4)
  'navigation_part_identifier' => string 'ezcontentnavigationpart' (length=23)
  'node_depth' => string '1' (length=1)
  'url_alias' => string '' (length=0)
  'current_language' => string 'eng-GB' (length=6)
  'language_mask' => string '3' (length=1)
  'main_node_id' => string '2' (length=1)
  'main_node_url_alias' => boolean false
  'persistent_variable' => 
    array
      'css_files' => 
        array
          0 => string 'video.css' (length=9)
      'js_files' => 
        array
          0 => string 'video.js' (length=8)
  'class_group' => boolean false
  'state' => 
    array
      2 => string '1' (length=1)
  'state_identifier' => 
    array
      0 => string 'ez_lock/not_locked' (length=18)
  'parent_class_id' => string '1' (length=1)
  'parent_class_identifier' => string 'folder' (length=6)
  'parent_node_remote_id' => string '629709ba256fe317c3ddcee35453a96a' (length=32)
  'parent_object_remote_id' => string 'e5c9db64baadb82ab8db54f0e2192ec3' (length=32)