eZ Community » Forums » Install & configuration » No more $node variable in pagelayout
expandshrink

No more $node variable in pagelayout

No more $node variable in pagelayout

Wednesday 17 January 2007 11:03:58 am - 2 replies

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.

Wednesday 17 January 2007 12:50:18 pm

$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}

Wednesday 17 January 2007 1:31:45 pm

ah, thank you very much. now i understand.

expandshrink

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu

Proudly Developed with from