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.

eZ debug

Timing: Jan 18 2025 01:07:44
Script start
Timing: Jan 18 2025 01:07:44
Module start 'layout'
Timing: Jan 18 2025 01:07:44
Module start 'content'
Timing: Jan 18 2025 01:07:44
Module end 'content'
Timing: Jan 18 2025 01:07:44
Script end

Main resources:

Total runtime0.7517 sec
Peak memory usage4,096.0000 KB
Database Queries60

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0068 587.7891152.6094
Module start 'layout' 0.00680.0031 740.398439.4375
Module start 'content' 0.00980.7403 779.8359580.6406
Module end 'content' 0.75010.0015 1,360.476612.1953
Script end 0.7516  1,372.6719 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00340.4472160.0002
Check MTime0.00130.1751160.0001
Mysql Total
Database connection0.00150.193310.0015
Mysqli_queries0.695892.5647600.0116
Looping result0.00060.0840580.0000
Template Total0.719495.720.3597
Template load0.00230.302320.0011
Template processing0.717295.409620.3586
Template load and register function0.00020.028710.0002
states
state_id_array0.00090.123410.0009
state_identifier_array0.00160.214420.0008
Override
Cache load0.00190.2507230.0001
Sytem overhead
Fetch class attribute can translate value0.00060.079730.0002
Fetch class attribute name0.00120.156950.0002
XML
Image XML parsing0.00100.136430.0003
class_abstraction
Instantiating content class attribute0.00000.001450.0000
General
dbfile0.00190.2472210.0001
String conversion0.00000.001240.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
3content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
4content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
2content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
1content/datatype/view/ezxmltags/link.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/link.tplEdit templateOverride template
1content/datatype/view/ezxmltags/li.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/li.tplEdit templateOverride template
1content/datatype/view/ezxmltags/ul.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/ul.tplEdit templateOverride template
1content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 15
 Number of unique templates used: 9

Time used to render debug report: 0.0001 secs