Forums / Developer / Get current node within an operator / Comment49766
André R.
Thursday 26 June 2008 7:40:38 am
Look in the first parameter in your modify function on the template operator class ( $tpl ).
Example code (if in pagelayout):
if ( $tpl->hasVariable('module_result') ) { $moduleResult = $tpl->variable('module_result'); } if ( $tpl->hasVariable('current_node_id') ) { $currentNodeId = (int) $tpl->variable('current_node_id'); } else if ( isset( $moduleResult['node_id'] ) ) { $currentNodeId = (int) $moduleResult['node_id']; } else if ( isset( $moduleResult['path'][count( $moduleResult['path'] ) - 1]['node_id'] ) ) { $currentNodeId = (int) $moduleResult['path'][count( $moduleResult['path'] ) - 1]['node_id']; }
if in node template just use the $node variable.
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