Navigation
eZ Documentation Center
 

This is outdated documentation made for eZ Publish Platform 5.1. It is being moved into the eZ Publish 5.x documentation, so please go there for most up-to-date documentation.

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

eZ Publish 5.1 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.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.getReturns a parameter by name.
ezpublish.legacy.hasReturns 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:

Code Block
titleExample on retrieving the available parameters under ezpublish.legacy
{{ dump(ezpublish.legacy.keys()) }}

which will give a result similar to:

No Format
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, 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:

Code Block
titleExample on accessing 'content_info' under ezpublish.legacy
{{ 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:

No Format
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)

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:

Code Block
titleExample on retrieving 'current_language'
{{ ezpublish.legacy.get('content_info')['current_language'] }}