【问题标题】:Drupal 7 theme_hook_suggestions not workingDrupal 7 theme_hook_suggestions 不工作
【发布时间】:2012-05-02 19:30:32
【问题描述】:

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

这是我的有效代码:

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

HTML 模板页面调用:html--qrule.tpl.php

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

但我也想用page--qrule.tpl.php 覆盖page.tpl.php 但是当我添加这个时:

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

PAGE模板页面调用: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

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

谢谢 C

【问题讨论】:

    标签: drupal drupal-7 drupal-views


    【解决方案1】:

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-12-30
      • 1970-01-01
      相关资源
      最近更新 更多