Created
December 1, 2010 20:36
-
-
Save dustincurrie/724169 to your computer and use it in GitHub Desktop.
Theme node body with a template file in the feature
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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