1-866-277-9958

Theme node body with a template file in the feature

This code can be used to add tpl.php files instead of implementing theme functions to your 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;
    }
  }
}

No votes yet
Syndicate content

©1999 - 2011 LevelTen Interactive - Dallas, TX