[development] how template suggestion inherits default header&footer of page.tpl.php

Wang Zi Feng frank.zifeng at gmail.com
Wed Jan 6 11:50:47 UTC 2010


Hi,

There is a rookie question.

I use template_preprocess_page function in a module to specify a template
file (news.tpl.php) based on the hook_menu path (?q=news), utilizing the
news.tpl.php every time click on ?q=news, it works fine.

But I have to copy the footer&header from page.tpl.php to the new template
file (news.tpl.php) to print them, I wonder if there is an approach to
inherit automatically the footer and header section?

here is the code

function news_menu(){
     $items['news'] = array(
        'title' => 'News',
        'page callback' => 'news_page_default',
        'access callback'=>TRUE,
        'type' => MENU_CALLBACK,
        );

     return $items;
}

function template_preprocess_page(&$variables){

    if(drupal_strtolower(arg(0))=='news'){
    $variables['template_file']='news' ;
    }

}

Thanks

Wang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.drupal.org/pipermail/development/attachments/20100106/f0feed9b/attachment-0001.html 


More information about the development mailing list