custom page-xxxx.tpl.php doesnt works

时间秒杀一切 提交于 2019-12-13 16:15:15

问题


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.



来源:https://stackoverflow.com/questions/11226362/custom-page-xxxx-tpl-php-doesnt-works

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!