Я создал новую тему drupal 7 и попытался реализовать hook_theme в template.php следующим образом:
function mytheme_theme($existing, $type, $theme, $path){ return array( 'mytheme_header'=>array( 'template'=>'header', 'path'=>$path.'/templates', 'type'=>'theme', ), ); } затем я поместил header.tpl.php в каталог шаблонов и очистил все кеши и вызвал функцию темы:
 theme('mytheme_header', $vars); 
и header.tpl.php это нравится:
 <?php fb('calling header template');//the function of FirePHP to output debug info print '<div>Header</div>'; //... 
Я проверяю Firebug, и он получает шаблон заголовка информации, он означает, что он вызвал header.tpl.php, но он не распечатывал html-код. Что случилось с моим кодом?
  Попробуйте добавить массив variables в hook_theme 
 function mytheme_theme($existing, $type, $theme, $path){ return array( 'mytheme_header' => array( 'template' => 'header', 'path' => $path . '/templates', 'type' => 'theme', 'variables' => array( 'title' => NULL, 'some_text' => NULL, ), ), ); } 
  В файле header.tpl.php : 
 <h1><?php print $title; ?></h1> <p><?php print $some_text; ?></p> 
Затем распечатайте его следующим образом:
 $vars = array(); $vars['title'] = "This is a title"; $vars['some_text'] = "Some text..."; print theme('mytheme_header', $vars);