小编Jap*_*ape的帖子

Drupal 7 hook_theme()没有加载模板文件

我正在尝试使用drupal的hook_theme()来获取一个非常简单的模块来加载模板文件.它几乎和你想象的一样简单.

function sectionheader_theme ( $existing, $type, $theme, $path ) {
  return array(
    'sectionheader' => array(
      'variables' => array( 'foo' => NULL ),
      'template' => 'sectionheader',
    ),
  );
}
Run Code Online (Sandbox Code Playgroud)

该模板名为sectionheader.tpl.php.该模块的其余部分正在按预期工作.我已经清除了Drupal缓存.我在这个函数中插入了一个die("Debug")语句,它正在被执行,但我的模板根本就没有被调用过.模板中只有一些调试文本,所以我可以看到它正在工作,但在模块的任何视图中都不可见.

我已经完成了我能找到的每个例子中的所有内容,我甚至直接从其他模块复制并粘贴了代码,这个模板仍然无法加载.

drupal drupal-7 drupal-themes drupal-theming

3
推荐指数
1
解决办法
6273
查看次数

标签 统计

drupal ×1

drupal-7 ×1

drupal-themes ×1

drupal-theming ×1