Php 如何在Drupal7中实现hook_主题?

Php 如何在Drupal7中实现hook_主题?,php,drupal,drupal-7,drupal-theming,Php,Drupal,Drupal 7,Drupal Theming,我创建了一个新的drupal 7主题,并尝试在template.php上实现hook_主题,如下所示: function mytheme_theme($existing, $type, $theme, $path){ return array( 'mytheme_header'=>array( 'template'=>'header', 'path'=>$path.'/templates',

我创建了一个新的drupal 7主题,并尝试在template.php上实现hook_主题,如下所示:

function mytheme_theme($existing, $type, $theme, $path){
    return array(
        'mytheme_header'=>array(
            'template'=>'header',
            'path'=>$path.'/templates',
            'type'=>'theme',
        ),
    );
}
$vars = array();
$vars['title'] = "This is a title";
$vars['some_text'] = "Some text...";
print theme('mytheme_header', $vars);
然后我将header.tpl.php放入templates目录并清除所有缓存,然后调用theme函数:

theme('mytheme_header', $vars);
header.tpl.php如下所示:

<?php
fb('calling header template');//the function of FirePHP to output debug info
print '<div>Header</div>';
//...

尝试在
hook\u主题中添加
变量
数组

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>

Drupal 7将
参数
重命名为
变量
,这不是变量的问题。我用FireHP调试,发现它调用了header.tpl.php,但它没有打印任何html代码。很抱歉,我调用了
theme($hook,$vars)
,但我应该调用
print theme($hook,$vars)