Posted on by & filed under Content - Highlights and Reviews, Web Development.

While some people think you can spot a Drupal site from its design, the truth is that Drupal can take on any shape you want it to. For example, take a look at the DrupalCon Denver site as opposed to The differences you see are the result of theming.

Creating your first theme

New themers think that to learn how to theme, they need to start a theme from scratch, but a much quicker and easier way to learn is to start with a base theme and then modify it using what’s called a subtheme. The Zen theme has great documentation on how to create a subtheme using Zen as the base theme.

Finding the right template or theme function

When a page is being loaded, the content to be displayed is managed by preprocess functions. These create the variables that are then converted into HTML by templates and theme functions.

As a themer, it’s important to understand that a page doesn’t have a single monolithic template. Instead, the theme system works kind of like a nested doll. There is a template for the page, which pulls together the output of templates for different regions of the page, which are composed of the output of other templates, and so on.

To find out the hierarchy of templates that are outputting a certain part of the page, you can use the Theme Developer module. Check the “Themer info” checkbox in the bottom left corner of the page to turn it on. Then, when you click on the element in question, it will list all of the templates and theme functions used as well as the preprocess functions that add variables for them to use.

Overriding template and theme function output

To override a template, you copy the template you want to override to your theme’s root folder. To override a theme function, you copy and paste the theme function you want to override to your theme’s template.php file. Then, in the function name you change the word “theme” to the name of your theme.

In both cases, you have to clear the site’s cache (located at config/development/performance) before you see the changes. To get more details on how to do this, take a look at the many Drupal books that can be found in Safari Books Online.

Safari Books Online has the content you need

Here are some great Drupal resources in Safari Books Online that can help you with your Drupal themes:

Design and Prototyping for Drupal provides an overview of how Drupal outputs content, how to design around that visually, and gives you an overview of turning the design into a theme.
Drupal 7 Themes is a practical guide that shows you how to create themes for your Drupal 7 site.
The Definitive Guide to Drupal covers every aspect of Drupal, from planning a successful project to making a living from designing Drupal sites, and even to contributing to the Drupal community yourself.

About this author

Lin Clark is a Drupal developer specializing in Linked Data. She contributed to the RDF in Drupal 7 core initiative, created SPARQL Views as part of the 2010 Google Summer of Code, and has spoken extensively about the benefits of using Linked Data technologies in everyday applications. She attended Carnegie Mellon University and is currently pursuing a research Master’s at the Digital Enterprise Research Institute at NUI Galway. More information is available at

Tags: Drupal, subtheme, themes,

One Response to “Getting Started with Drupal Themes”