1
我加入以下到我的template.php文件中,在[THEMENAME] _preprocess_page功能:的Drupal 7不使用模板建議
<?php
if ($variables['is_front'])
{
$variables['theme_hook_suggestions'] = array();
$variables['theme_hook_suggestions'][] = 'page__index';
}
if (isset($variables['node'])) {
// If the node type is "blog" the template suggestion will be "page--blog.tpl.php".
$variables['theme_hook_suggestions'][] = 'page__'. str_replace('_', '--', $variables['node']->type);
}
如果我運行$變量陣列上的var_dump,我可以看到在我的頭版上,'theme_hook_suggestions'被設置爲只使用'page__index'。我有一個名爲'page - index.tpl.php'的文件。 Drupal仍然使用page.tpl.php。
我也註釋掉了上面的代碼,並將該文件重命名爲'page - front.tpl.php',它仍然使用page.tpl.php。每次更改後我都清除緩存。
我錯過了什麼?
編輯:爲了幫助澄清,我想覆蓋前面頁面的整個設計 - 沒有列或側邊欄,不同的圖形,一些div的不同背景等。我不想覆蓋'node - '模板文件(還)。最後,我需要一個靜態的首頁,其設計與網站其他部分不同,然後是每個內容類型的自定義節點模板。