2

I have page named page--news.tpl.php, which i created for my news page. But after i cleared my cache, page still not using, and drupal use the original page.tpl.php. Any ideas how to solve it?

4

1 回答 1

3

另一种方法是通过几行代码的预处理钩子。这是怎么回事

function <module_name>_preprocess_page(&$variables) {
    if (isset($variables['node'])) {
        $variables['theme_hook_suggestions'][] = 'page__'.$variables['node']->type;
    }
}

假设您有一个节点类型为“news”,那么 tpl 应该看起来像“page--news.tpl.php”,上面的代码将处理其余部分。

于 2012-06-28T00:41:00.653 回答