Overriding base theme elements in a sub-theme
This recipe details the steps involved in overriding a base theme template file. We will be restructuring the layout of a Drupal node by modifying the node.tpl.php
template.
Getting ready
We will be using the mytheme
sub-theme which was created in the previous recipe.
How to do it...
As we are dealing with a sub-theme here, it is by default relying on the template files of its base theme. To override the base file used to theme the layout of a node, copy the node.tpl.php
file from the base theme's folder—themes/garland
—to the sites/themes/mytheme
folder. Opening the new file in an editor should bring up something similar to the following:
<?php // $Id: node.tpl.php,v 1.5 2007/10/11 09:51:29 goba Exp $ ?> <div id="node-<?php print $node->nid; ?>" class="node<?php if ($sticky) { print ' sticky'; } ?><?php if (!$status) { print ' node-unpublished'; } ?>"> <?php print $picture ?> <?php if ($page == 0): ?> ...