繁体   English   中英

Drupal 6 - 模块中的自定义节点类型模板

[英]Drupal 6 - Custom Node Type Template in Module

我有一个添加新内容类型的模块。

对于此内容类型,我想提供 node_contenttype.tpl.php 节点类型模板,但 Drupal 将无法在模块目录中识别此模板,只能在主题中识别。

如何让 Drupal (6) 使用我的模板?

您可以使用hook_theme_registry_alter()

这是一个在适合我的自定义模块中使用的示例(只需将“mymodule”替换为您的模块名称):

/**
 * Implementation of hook_theme_registry_alter()
 */
function mymodule_theme_registry_alter(&$theme_registry) {
  $template = 'node';
  $originalpath = array_shift($theme_registry[$template]['theme paths']);
  $modulepath = drupal_get_path('module', 'mymodule');
  // Stick the original path with the module path back on top
  array_unshift($theme_registry[$template]['theme paths'], $originalpath, $modulepath);
}

现在,Drupal 将检查您的模块文件夹中的节点模板覆盖。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM