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?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
An alternate way of doing it, is through preprocess hook with few lines of code. Here's how it goes
function <module_name>_preprocess_page(&$variables) {
if (isset($variables['node'])) {
$variables['theme_hook_suggestions'][] = 'page__'.$variables['node']->type;
}
}
Suppose you have a node type as "news" then tpl should look like 'page--news.tpl.php' and above code will handle the rest.