我在这里慢慢失去了理智:
我需要为特定词汇表的术语做一个模板。我创建了一个子主题,并尝试使用theme_preprocess_page() ( theme_preprocess_taxonomy_term()不知何故从未被调用)。
template.php
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
<h1>MYVOCAB TEST</h1>每次都清除缓存,没有任何更改。:c
有什么想法吗?
发布于 2014-09-17 04:31:37
我认为这可能是因为您将建议添加到数组的开头而不是末尾。
取代:
$variables['theme_hook_suggestions'][0] = 'page__vocabulary__' . $term->vocabulary_machine_name;通过以下方式:
$variables['theme_hook_suggestions'][] = 'page__vocabulary__' . $term->vocabulary_machine_name;https://stackoverflow.com/questions/25875462
复制相似问题