Drupal themes are based on template files, defined with the extension .tpl.php
.
What is a .tpl.php ? the page.tpl.php. This template file contains the code for the body of the page.
regions[header] = Header
regions[sidebar_first] = Right sidebar
regions[content] = Content
regions[footer] = Footer
stylesheets[all][] = css/style.css
stylesheets[print][] = css/print.css
features[] = name
features[] = main_menu
Create the page.tpl.php
Example .tpl
<div id=”header”>
</div>
<div id=”wrapper”>
<div id=”content”>
</div>
<div id=”sidebar”>
</div>
</div>
<div id=”footer”>
</div>
Create a region
Drupal interface (via Blocks) needs to become a region. In our sample site, this includes header, right sidebar, content area, and footer. Don’t forget that all of your regions need to be introduced in the .info
file first.
<?php if ($page[‘footer’]): ?>
<?php print render($page[‘footer’]); ?>
<?php endif; ?>
sample page.tpl.php
<div id=”header”>
</div>
<div id=”wrapper”>
<div id=”content”>
<?php print render($page[‘content’]); ?>
</div>
<?php if ($page[‘sidebar_first’]): ?>
<div id=”sidebar”>
<?php print render($page[‘sidebar_first’]); ?>
</div>
<?php endif; ?>
</div>
<div id=”footer”>
<?php if ($page[‘footer’]): ?>
<?php print render($page[‘footer’]); ?>
<?php endif; ?>
</div>
Add variables for basic page elements
$site_name
$logo
(the logo uploaded through the theme settings; only useful when you’re implementing the logo theme feature)$title
(the page title)$main_menu
$secondary_menu
$breadcrumbs
There are also some variables associated with Drupal administration:
$tabs
(menu used for edit/view admin menus, among other things; often used by modules)$messages
$action_links
And some other useful variables:
$base_path
(the path to your site root)$front_page
(the path to the site front page)$directory
(the path to your theme)
Example:
<footer><?php print render($page[name of the page example: footer ] ):? ></footer>
<article><?php print render($page[name of the page example: article ] ):? ></article>