Global navigation

   Documentation Center
   eZ Studio & eZ Platform
     User Manual
     Technical Manual
     Glossary
   eZ Publish 4.x / legacy

 
eZ Publish (5.x)

eZ Publish 5.x | For eZ Platform & eZ Studio topics see Technical manual and User manual, for eZ Publish 4.x and Legacy topics see eZ Publish legacy

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
titlemy_layout.html.twig
<!DOCTYPE html>
<html>
<head>
    <!-- ... -->
</head>
<body>
    {block content}{# Content will be inserted here #}{endblock}
</body>
</html>

 

Assets and persistent variable

...

Persistent variable

The persistent variable is a special variable in legacy templates that you can set in order to pass values from the content template to the pagelayout. This variable, among others, is accessible from the configured Twig pagelayout thanks to the helper ezpublish.legacy.

Actually, all data contained in $module_result in the legacy kernel is exposed.

Code Block
titleAccess to the persistent variable
<!DOCTYPE html>
<html>
<head>
    <!-- ... -->
    {% if ezpublish.legacy.has( 'content_info' ) %}
        {% set persistent_variable = ezpublish.legacy.get( 'content_info' )['persistent_variable'] %}
    {% endif %}
</head>
<body>
    {block content}{# Content will be inserted here #}{endblock}
</body>
</html>

Assets

Like the persistent variable, it is possible to require css and/or javascripts assets from a content template through the legacy ezscript_require() and ezcss_require() template operators.

You can easily retrieve those requested assets from the legacy template in the Twig pagelayout with the ezpublish.legacy helper.

Code Block
titleGetting assets requested from a legacy template
<!DOCTYPE html>
<html>
<head>
    <!-- ... -->
    {% set requested_css_files = ezpublish.legacy.get( 'css_files' ) %}
    {% set requested_js_files = ezpublish.legacy.get( 'js_files' ) %}
 
    {# "configured" assets are the ones defined in design.ini (FrontendCSSFileList/FrontendJavaScriptList) #}
    {% set configured_js_files = ezpublish.legacy.get( 'js_files_configured' ) %}
    {% set configured_css_files = ezpublish.legacy.get( 'css_files_configured' ) %}
</head>
<body>
    {block content}{# Content will be inserted here #}{endblock}
</body>
</html>