簡體   English   中英

無法按節點類型覆蓋html.tpl.php

[英]Override html.tpl.php per node type does not work

我看到這是以前問過的幾次,我嘗試了答案,然后嘗試修改了答案,但什么也沒有。

案例:我已經安裝了高級論壇,並且我正在使用appcache(現在不要讓親愛的人逃跑!)顯然,在瀏覽論壇時我需要關閉appcache,並且我設法為/ forum創建了自定義html.tpl.html。和/ forums,所以當我查看論壇列表和主題列表時,不會被緩存。 但是然后:當我查看論壇主題時,它是一個帖子,並且帖子類型(機器類型是論壇)並且我已經在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的路徑,但不能更改節點的類型。 請幫助我,並糾正我做這些事的知識。

謝謝大家!!! (順便說一句,我不需要上一堂應用程序緩存,誠摯的,如果您的html標記中有manifest = x.appcache“,即使它在網絡部分中,它也會緩存它)

$vars['theme_hook_suggestions']$vars['theme_hook_suggestion']之間略有差異。

$vars['theme_hook_suggestions']是主題建議的數組 ,並在該陣列的端部的模板具有比之前的部分更高的優先級。

// 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;

天哪,我為您感到抱歉。

應該是$vars['theme_hook_suggestions']而不是$vars['theme_hook_suggestion'] (建議末尾的s)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM