Skip to content

Instantly share code, notes, and snippets.

@dustincurrie
Created December 1, 2010 20:36
Show Gist options
  • Save dustincurrie/724169 to your computer and use it in GitHub Desktop.
Save dustincurrie/724169 to your computer and use it in GitHub Desktop.
Theme node body with a template file in the feature
<?php
/**
* Implementation of hook_theme().
* DRUPAL WONT SEE THIS HOOK UNTIL YOU CLEAR YOUR CACHE
*/
//Create myfeature-node-body.tpl.php in your feature and use $node to theme the node body
function myfeature_theme() {
return array(
'myfeature-node-body' => array(
'template' => 'myfeature-node-body',
'arguments' => array('node' => null),
),
);
}
/**
* Implementation of hook_nodeapi().
*/
function myfeature_nodeapi(&$node, $op, $a3, $a4) {
if ($node->type == 'mytype') {
switch($op) {
case 'view':
$node->content['body'] = array(
'#value' => theme('myfeature-node-body', $node),
'#weight' => 10,
);
break;
case 'load':
//add any extra data your template needs to $node here
break;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment