No more $node variable in pagelayout

Author Message

Andreas Adelsberger

Wednesday 17 January 2007 2:03:58 am

please correct me if i got something wrong, but since updating to 3.9 $node is no longer availabe in the templates.

here is my workaround if you don't want to modify all your templates:

in pagelayout.tpl:

{def $node = fetch( content, node, hash( node_id, $module_result.node_id ) )}

now you can still use {$node}.

i think the documentation should be changed because there are still all the examples using $node.

---------------------------------------
Styleflasher New Media OG
Websites. Games/Multimedia.

André R.

Wednesday 17 January 2007 3:50:18 am

$node is still available in node templates, but from 3.9 and higher it is removed from pagelayout and related templates.
This is with good reason since $node is not set in pagelayout when viewcache is turned on and you are viewing a cached node page, and it's never set in pagelayout on pages that are not content related.

So if you need to use current node in your pagelayout, do something like this:

{def $current_node_id  = first_set($module_result.node_id, 0)}
{if $current_node_id}
{def $current_node = fetch( content, node, hash( node_id, $current_node_id ) )}
{/if}

If you absolutely need $node present in your pagelatout:

{if and( is_set($module_result.node_id), is_unset($node) )}
{def $node = fetch( content, node, hash( node_id, $module_result.node_id ) )}
{/if}

eZ Online Editor 5: http://projects.ez.no/ezoe || eZJSCore (Ajax): http://projects.ez.no/ezjscore || eZ Publish EE http://ez.no/eZPublish/eZ-Publish-Enterprise-Subscription
@: http://twitter.com/andrerom

Andreas Adelsberger

Wednesday 17 January 2007 4:31:45 am

ah, thank you very much. now i understand.

---------------------------------------
Styleflasher New Media OG
Websites. Games/Multimedia.

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 18 2025 19:13:13
Script start
Timing: Jan 18 2025 19:13:13
Module start 'layout'
Timing: Jan 18 2025 19:13:13
Module start 'content'
Timing: Jan 18 2025 19:13:13
Module end 'content'
Timing: Jan 18 2025 19:13:13
Script end

Main resources:

Total runtime0.0143 sec
Peak memory usage2,048.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0051 588.0391152.6406
Module start 'layout' 0.00510.0029 740.679739.4766
Module start 'content' 0.00800.0040 780.156393.4922
Module end 'content' 0.01200.0022 873.648434.3047
Script end 0.0142  907.9531 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002215.7069140.0002
Check MTime0.00117.5284140.0001
Mysql Total
Database connection0.00085.481310.0008
Mysqli_queries0.002618.524430.0009
Looping result0.00000.098610.0000
Template Total0.001711.610.0017
Template load0.00096.056110.0009
Template processing0.00085.523110.0008
Override
Cache load0.00064.263010.0006
General
dbfile0.00032.110680.0000
String conversion0.00000.068540.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs