The Definitive Guide to Drupal 7

Overriding Template Files

The template files provided by Drupal core and contributed modules represent the default markup implementation chosen by the original author or team, but every last one of these template files—and the markup and variables printed inside of them—is customizable. When developing a theme, if you decide the default implementation is not going to suit your needs, you can simply choose to override it. Drupal’s theme layer is designed to be extremely flexible and easy to manipulate in this way.

The beauty of theming Drupal sites is that you can easily make changes without having to modify templates where they originate. The process of overriding template files is extremely simple:

  1. Find the original template file by browsing through code or checking
  2. Copy and paste it into your theme directory.
  3. Clear the site cache and reload!

After following these three steps, Drupal will begin using the theme’s version of the file, and you are free to make whatever changes you wish. It’s that simple.

You are reading content from two chapters on Theme Development from The Definitive Guide to Drupal 7, written by Jacine Luisi and published by Apress on July 19, 2011. All rights reserved.