I'm creating a drupal template and tried using this
<?php require "".base_path() . path_to_theme()."'/header.php'" ?>
and it does provide the right path, but it gave this
Warning: require(/learn/learn_drupal/sites/all/themes/test_theme'/header.php'): failed to open stream: No such file or directory in require() (line 33 of /Users/Devric/Sites/learn/learn_drupal/sites/all/themes/test_theme/templates/html.tpl.php).
anyone know how to separate the code?
If I were you I'd read up on how to set a proper Drupal theme.
Start by building a templates folder in your theme directory. Then copy over from the root modules/system/page.tpl.php
and modules/system/html.tpl.php
to this new templates folder.
This is your main theme files. html.tpl.php contains everything in your header (meta tags etc) and your start and end body tags.
page.tpl.php is what goes in between the body, or basically what is printed where it says <?php print $page; ?>
.
If you open the page.tpl.php file you'll see all your regions etc. This is your page outline. Use this as to sort out any footers, headers etc using either hard code or Drupal's excellent block system.
If you think of your page like this is should help:
html.tpl.php -> opens your html page
- page.tpl.php -> any constant elements above the content
- node.tpl.php -> the content
- page.tpl.php -> any constant elements below the content
html.tpl.php -> closes your html page
You don't need to set up your own includes because Drupal already does all this for you. It's a steep learning curve and I really struggled to start off with but there's no point not doing things the Drupal way as you're losing what makes it such a good CMS.
You can read more here - http://drupal.org/documentation/theme
EDIT:
You can set up blocks to be page specific and then theme them. Set up a block called about header for example and set to only be displayed on the pages you want it on in the blocks admin page. You can set templates up for each block in the same way you do nodes.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With