hi tim and michael,<br><br>After some investigation, I found an way from different angle to resolve my problem.<br><br>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.<br>
<br><br>function phptemplate_preprocess_page(&$variables){<br><br>$variables['global_header']=global_header()<br><br>}<br><br>function global_header(){<br><br>return "Global Header Here";<br><br>}<br>
<br>Wang<br><br><div class="gmail_quote">2010/1/7 Michael Favia <span dir="ltr"><<a href="mailto:michael.favia@gmail.com">michael.favia@gmail.com</a>></span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
What Tim is describing at the end of his message might be alittle<br>
confusing but is VERY essential. The page template suggestions and<br>
indeed all template suggestions use "original paths" (e.g. node/15)<br>
and not path aliases (news/my-name-is). This makes using them with out<br>
specific template suggestions (on node type, etc) in the preprocess<br>
function almost useless in most of my cases.<br>
<br>
Tim is also right in alluding to the node.tpl.php template files<br>
which, by default DO load conditionally on node type. If you are just<br>
looking to modify the node display contents look here. If you need to<br>
modify contents outside this page then youll have to live with a<br>
little code duplication in page template or conditionally include the<br>
header and footer sections as includes(). Good luck, -mf<br>
<div><div></div><div class="h5"><br>
On Wed, Jan 6, 2010 at 7:02 AM, T L <<a href="mailto:tloud365@gmail.com">tloud365@gmail.com</a>> wrote:<br>
> Hi Wang,<br>
><br>
> What kind of content are you trying to customize? If it's a node, you can<br>
> do something like node-my_node_type.tpl.php. This would change the theme<br>
> around the various node types, but use a common page.tpl.php file to supply<br>
> the header, menu, footer, etc.<br>
><br>
> You can override all of the *.tpl.php files like block, page, comment, etc<br>
> in slightly different ways. Which is generally, I think, how you would do<br>
> something like this dependent on the kind of content you want to theme. As<br>
> a specific example, you can just create page-news.tpl.php for a unique<br>
> ?q=news theme. (There's a gotcha though, so just make sure it's the<br>
> original path, you will need to adjust if you use path aliasing like<br>
> path_auto.)<br>
><br>
> Cheers,<br>
> Tim<br>
><br>
> On Wed, Jan 6, 2010 at 6:50 AM, Wang Zi Feng <<a href="mailto:frank.zifeng@gmail.com">frank.zifeng@gmail.com</a>> wrote:<br>
>><br>
>> Hi,<br>
>><br>
>> There is a rookie question.<br>
>><br>
>> I use template_preprocess_page function in a module to specify a template<br>
>> file (news.tpl.php) based on the hook_menu path (?q=news), utilizing the<br>
>> news.tpl.php every time click on ?q=news, it works fine.<br>
>><br>
>> But I have to copy the footer&header from page.tpl.php to the new template<br>
>> file (news.tpl.php) to print them, I wonder if there is an approach to<br>
>> inherit automatically the footer and header section?<br>
>><br>
>> here is the code<br>
>><br>
>> function news_menu(){<br>
>> $items['news'] = array(<br>
>> 'title' => 'News',<br>
>> 'page callback' => 'news_page_default',<br>
>> 'access callback'=>TRUE,<br>
>> 'type' => MENU_CALLBACK,<br>
>> );<br>
>><br>
>> return $items;<br>
>> }<br>
>><br>
>> function template_preprocess_page(&$variables){<br>
>><br>
>> if(drupal_strtolower(arg(0))=='news'){<br>
>> $variables['template_file']='news' ;<br>
>> }<br>
>><br>
>> }<br>
>><br>
>> Thanks<br>
>><br>
>> Wang<br>
>><br>
><br>
><br>
><br>
> --<br>
> Tim Loudon<br>
> (781) 686-6096<br>
><br>
</div></div></blockquote></div><br>