【问题标题】:Override html.tpl.php per node type does not work覆盖每个节点类型的 html.tpl.php 不起作用
【发布时间】:2014-05-05 12:02:12
【问题描述】:

我看到之前有人问过这个问题,我尝试了答案,我尝试修改答案,但没有。

案例:我安装了高级论坛,我正在使用 appcache(亲爱的你现在逃跑了吗!)显然我在浏览论坛时需要关闭 appcache,我设法制作了自定义 html.tpl.html对于 /forum 和 /forums,所以当我查看论坛列表和主题列表时,我不会被缓存。但是后来:当我查看论坛主题时,它是一个post ofc,并且帖子类型(机器类型是论坛)并且我在template.php中定义了:

function flowrox_preprocess_html(&$vars) {
    $node = menu_get_object();

    if ($node && $node->nid) {
        $vars['theme_hook_suggestion'][] = 'html__' . $node->type;
    }
}

它不会做出改变。

所以我可以更改 html.tpl.php 的路径,但不能更改节点类型。请帮助我并纠正我制作此类东西的知识。

谢谢大家!!! (顺便说一句,我不需要 appcache 的课程,真诚地,如果你的 html 标签中有 manifest = x.appcache" 它会缓存它,即使它在网络部分)

【问题讨论】:

  • mb 清除 drupal 主题缓存?可悲的是,那个“解决方案”帮助了我几次
  • 没用 ;_;尝试了 5 次,总是在我进行更改时
  • 你在什么钩子上添加了theme_hook_suggestions,你能发布所有的theme_hook_suggestions吗?
  • 编辑后凹凸等

标签: php drupal drupal-7 drupal-theming


【解决方案1】:

$vars['theme_hook_suggestions']$vars['theme_hook_suggestion'] 之间存在细微差别。

$vars['theme_hook_suggestions']是主题建议的ARRAY,该数组末尾的模板优先级高于前面的模板。

// example
$vars['theme_hook_suggestions'][] = 'html__' . $node->type;

$vars['theme_hook_suggestion'] 是一个STRING,表示要使用的模板文件,它的优先级高于$vars['theme_hook_suggestions']。这意味着如果将任何主题建议传递给$vars['theme_hook_suggestion']$vars['theme_hook_suggestions'] 将被忽略。

// example
$vars['theme_hook_suggestion'] = 'html__' . $node->type;

【讨论】:

    【解决方案2】:

    O M G,我现在为你感到难过。

    应该是$vars['theme_hook_suggestions'] 而不是$vars['theme_hook_suggestion'] (建议末尾的 s)

    【讨论】:

    • 我现在持有这些感觉。你无法想象。但是,是的,感谢百万次的人
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-06-26
    • 1970-01-01
    • 2016-03-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-11-15
    相关资源
    最近更新 更多