相关疑难解决方法(0)

如何在drupal 7中实现hook_theme?

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

function mytheme_theme($existing, $type, $theme, $path){
    return array(
        'mytheme_header'=>array(
            'template'=>'header',
            'path'=>$path.'/templates',
            'type'=>'theme',
        ),
    );
}
Run Code Online (Sandbox Code Playgroud)

然后我将header.tpl.php放入模板目录并清除所有缓存,并调用主题函数:

theme('mytheme_header', $vars);
Run Code Online (Sandbox Code Playgroud)

和header.tpl.php赞了这个:

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

我检查Firebug,它获取信息'调用标题模板',这意味着它已调用header.tpl.php,但它没有打印html代码.我的代码出了什么问题?

php drupal drupal-7 drupal-theming

11
推荐指数
1
解决办法
2万
查看次数

标签 统计

drupal ×1

drupal-7 ×1

drupal-theming ×1

php ×1