【发布时间】:2012-01-02 20:21:32
【问题描述】:
我正在尝试开发一个模块,其输出将以与 Views 模块非常相似的方式进行主题化,但我似乎无法让它工作。我关注了使用主题层 (http://drupal.org/node/933976) 并搜索了drupal 论坛无济于事。
主题钩子在 hook_theme 中定义为
'beerxml_hop' => array (
'template' => 'beerxml-hop',
'render element' => 'beerxml',
'pattern' => 'beerxml_hop__',
'path' => drupal_get_path('module', 'beerxml_formatter') . '/templates',
)
我通过
调用主题钩子print render($element);
在node--beer.tpl.php(beer 是内容类型名称)中,$element 是带有#theme 的渲染数组
array(3) {
[0] => string(19) "beerxml_hop__simcoe"
[1] => string(11) "beerxml_hop"
[2] => string(15) "beerxml_unknown"
}
被调用的模板是beerxml_hop,而不是我希望的beerxml_hop__simcoe。 beerxml-hop--simcoe.tpl.php 和 beerxml-unknown.tpl.php 都存在于同一目录中,beerxml-hop.tpl.php 和 beerxml-unknown.tpl.php 在输出的其他地方使用。
我错过了什么? :)
【问题讨论】:
标签: drupal drupal-7 drupal-modules drupal-theming