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.