The persistent variable
This page is for designers who need the content template to influence the frame: hide a side column on a landing page, add a body class for a class, change the page title. The view template runs before the pagelayout and cannot reach it directly; the persistent variable carries the message.
Contents
Setting it
In a full view (or an override of it), set the template variable persistent_variable to a hash in the root scope:
set scope=global persistent_variable=hash( 'body_class', 'landing', 'left_menu', false() )The content view reads it after rendering (kernel/classes/eznodeviewfunctions.php: the kernel sets it to false
before the view runs and copies any other value into content_info).
Reading it
In the pagelayout:
{def $pv = cond( and( is_array( $module_result.content_info ), is_set( $module_result.content_info.persistent_variable ) ),
$module_result.content_info.persistent_variable, false() )}
<body class="if and( $pv, is_set( $pv.body_class ) )$pv.body_class|wash/if">Why "persistent"
The value is stored with the view cache entry (the kernel adds it to the cache keys), so a page served from the view cache delivers the same value as when it was rendered. A variable set any other way would be lost on a cache hit.
Helpers
ezcss_requireandezscript_requireuse the persistent variable to pass stylesheet and script lists.- The ezwebin extension's
ezpagedata_set( 'key', value )andezpagedata_appendwrite into it, andezpagedata()reads it back (The ezwebin design as a base).
Examples in the shipped designs
admin4's pagelayout reads persistent_variable.left_menu and extra_menu, so an edit page template can ask for its own
left column (design/admin4/templates/pagelayout.tpl).
Related pages
- Module result and content info
- Full view
- Free documentation: this page is free to copy, translate and improve under the GNU FDL 1.3.
Become an Exponential Partner
Partners share their information, provide funding, contribute back and develop the products with us, and that is how Exponential grows. A partner website and dashboard are planned for mid-2027: please become a partner today to speed up our growth rate and land new features faster.