Drupal 7 theme_hook_suggestions不起作用

时间:2012-05-02 19:30:32

标签: drupal drupal-7 drupal-views

如何为一个视图显示覆盖添加2?

这是我的代码:

function yourthemename_preprocess_html(&$vars) {
  if (arg(0) == 'qrule') {        
    $vars['theme_hook_suggestions'][] = 'html__qrule';        
  }
}

HTML模板页面名为:html--qrule.tpl.php

这很好用! (感谢@ Ionut.A)

但是我也希望用page.tpl.php覆盖page--qrule.tpl.php但是当我添加它时:

function mythemename_preprocess_html(&$vars) {
  if (arg(0) == 'qrule') {        
    $vars['theme_hook_suggestions'][] = 'html__qrule'; 
    $vars['theme_hook_suggestions'][] = 'page__qrule';    
  }
}

页面模板页面名为:page--qrule.tpl.php

我收到此错误:

Fatal error: Only variables can be passed by reference in /var/www/vhosts/xxx/public_html/sites/all/themes/themename/page--qrule.tpl.php on line 1

谁能看到我在这里做错了什么?

由于 ç

1 个答案:

答案 0 :(得分:3)

如果您要为page.tpl.php文件添加主题钩子建议,则需要在hook_preprocess_page()中添加:

function mythemename_preprocess_page(&$vars) {
  $vars['theme_hook_suggestions'][] = 'page__qrule';
}
相关问题