首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Drupal 7忽略了我的theme_hook_suggestions

Drupal 7忽略了我的theme_hook_suggestions
EN

Stack Overflow用户
提问于 2014-09-16 17:54:49
回答 1查看 210关注 0票数 0

我在这里慢慢失去了理智:

我需要为特定词汇表的术语做一个模板。我创建了一个子主题,并尝试使用theme_preprocess_page() ( theme_preprocess_taxonomy_term()不知何故从未被调用)。

template.php

代码语言:javascript
复制
function aura_sub2_preprocess_page(&$variables) {
  if (arg(0) == 'taxonomy' && arg(1) == 'term' && is_numeric(arg(2))) {
    $term = taxonomy_term_load(arg(2));
    drupal_set_message( 'page__vocabulary__' . $term->vocabulary_machine_name );
    $variables['theme_hook_suggestions'][0] = 'page__vocabulary__' . $term->vocabulary_machine_name;
  }
}

正如您所看到的,我甚至为测试目的覆盖了第一个建议,但没有任何改变。页面加载时好像什么都没发生过一样。当我打开“mydomain.com/?q=en/my词汇表/某个术语”时,我得到了状态消息"page__vocabulary__myvocabulary“。到目前为止还不错,但是模板建议似乎被忽略了。模板驻留在该子主题的“主题”目录中。我尝试了每一个可能的组合“-”和"__“,但没有结果。模板只包含这个,这是一个问题吗?:

theme/page--vocabulary--myvocabulary.tpl.php

代码语言:javascript
复制
<h1>MYVOCAB TEST</h1>

每次都清除缓存,没有任何更改。:c

有什么想法吗?

EN

回答 1

Stack Overflow用户

发布于 2014-09-17 04:31:37

我认为这可能是因为您将建议添加到数组的开头而不是末尾。

取代:

代码语言:javascript
复制
$variables['theme_hook_suggestions'][0] = 'page__vocabulary__' . $term->vocabulary_machine_name;

通过以下方式:

代码语言:javascript
复制
$variables['theme_hook_suggestions'][] = 'page__vocabulary__' . $term->vocabulary_machine_name;
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/25875462

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档