hi tim and michael,

After some investigation, I found an way from different angle to resolve my problem.

write phptemplate_preprocess_page function in template.php to build a global header variable which utilize a global_header function. Then you can simply print the global_header variable in any page.tpl.php file.


function phptemplate_preprocess_page(&$variables){

$variables['global_header']=global_header()

}

function global_header(){

return "Global Header Here";

}

Wang

2010/1/7 Michael Favia <michael.favia@gmail.com>
What Tim is describing at the end of his message might be  alittle
confusing but is VERY essential. The page template suggestions and
indeed all template suggestions use "original paths" (e.g. node/15)
and not path aliases (news/my-name-is). This makes using them with out
specific template suggestions (on node type, etc) in the preprocess
function almost useless in most of my cases.

Tim is also right in alluding to the node.tpl.php template files
which, by default DO load conditionally on node type. If you are just
looking to modify the node display contents look here. If you need to
modify contents outside this page then youll have to live with a
little code duplication in page template or conditionally include the
header and footer sections as includes(). Good luck, -mf

On Wed, Jan 6, 2010 at 7:02 AM, T L <tloud365@gmail.com> wrote:
> Hi Wang,
>
> What kind of content are you trying to customize?  If it's a node, you can
> do something like node-my_node_type.tpl.php.  This would change the theme
> around the various node types, but use a common page.tpl.php file to supply
> the header, menu, footer, etc.
>
> You can override all of the *.tpl.php files like block, page, comment, etc
> in slightly different ways.  Which is generally, I think, how you would do
> something like this dependent on the kind of content you want to theme.  As
> a specific example, you can just create page-news.tpl.php for a unique
> ?q=news theme.  (There's a gotcha though, so just make sure it's the
> original path, you will need to adjust if you use path aliasing like
> path_auto.)
>
> Cheers,
> Tim
>
> On Wed, Jan 6, 2010 at 6:50 AM, Wang Zi Feng <frank.zifeng@gmail.com> wrote:
>>
>> 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
>>
>
>
>
> --
> Tim Loudon
> (781) 686-6096
>