Some ideas after creating themes with Drupal 6

Grab the feed

School is a twelve-year jail sentence where bad habits are the only curriculum truly learned.

John Taylor Gatto

Recent comments

No doubt about it, moving from Drupal 5 to 6 is a good idea, sites run faster, the API is solid and the code clearer to understand.

But one of the things that took me more time to understand were the changes related to creating themes with Drupal 6.

These days I've been upgrading a couple of sites to Drupal 6 and have found a few important details that may save you some time:

  • You can use templates (tpl.php files) or theme_ functions but the documentation recommends using templates. Even if theme_ functions run faster templates are easier for non programmers.
  • Now each module can, and should, include its own templates. These can be overriden by a theme just by including a file with the same name as the original template in the theme directory.
  • Each module must use hook_theme to register the templates or theme_ functions that it will use. I was getting blank pages from some theme_ functions in a Drupal 5 module I was upgrading and the cause was I did not have a hook_theme in the module.
  • Most changes in hook_theme require clearing the cache at /admin/settings/performance.
  • All your business logic should be in preprocess functions that create or modify variables to be included in the templates.

That's it. What can you add? Tell us about your experience creating Drupal 6 themes.

Keep your comments relevant, written in good English and don't spam. Let's create useful and valuable discussions. Markdown is welcome.

Add your comment