No $node access

Author Message

Alan Fowler

Thursday 16 June 2011 5:30:09 am

Hi,

I have just done a new install of 4.3 but am unable to access anything using $node. The $module command works fine.

Any help please?

Thanks

Alan

Thiago Campos Viana

Thursday 16 June 2011 6:36:00 am

The variable $node is only available by default inside $node templates ( full/line/embed ), not in pagelayout.tpl neither in custom modules templates. You can either:

  • Define a $node variable;
  • Set the template variable in the module view php file ( $tpl->setVariable( 'node', eZContentObjectTreeNode::fetch($node_id ) ); ), so you'll be able to access it inside the module view tpl;

eZ Publish Certified Developer: http://auth.ez.no/certification/verify/376924

Twitter: http://twitter.com/tcv_br

Terry Duivesteijn

Tuesday 21 June 2011 1:49:19 pm

In addition to Thiago's response, here's a snippet you could place on top of your pagelayout:

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

-- Lead webdeveloper at Contactivity, Leiden, The Netherlands.
Contactivity is specialized in cross-media publications, websites driven on eZ Publish and content editing.
Certified developer: http://auth.ez.no/certification/verify/413879
Tw: http://twitter.com/#!/Duivesteijn

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