hi i am new to drupal, i am creating a theme, i want to create theme header and footer separately and include them in each page. in custom php we just create 1 header and footer.php files and include them with the include() function. now please guide me whether i have to include them as in custom php or is there any other way to do this in drupal.

Comments

Anonymous’s picture

I'm not sure if it's the 'correct' way but I'd create a separate theme for your header and footer files, implement hook_preprocess_page in your template.php file and add the header and footer as page vars, something like this:

function mytheme_preprocess_page(&$vars) {
  $vars['my_header'] = theme('my_header');
  $vars['my_footer'] = theme('my_footer');
}

Then you can output the variables just like any other in your page.tpl.php file:

print $my_header;
...rest of page...
print $my_footer
sheraz4pro’s picture

i have created a header file my_header.tpl.php in themes folder.
then in template file i put following code in the template file

bluemarin_preprocess_page(&$vars){
      $vars['my_header'] = theme('my_header');
}

now i am using to display it in page.tpl by using this line of code

    print render($page['header']);
    print $my_header;
   

but its not displaying anything :(

Anonymous’s picture

I'd guess you haven't registered your theme function in hook_theme, documentation is here:

http://api.drupal.org/api/drupal/developer--hooks--core.php/function/hoo...