Converting Drupal 5 Themes to Drupal 6

posted by Ishmael Sanchez on Apr 30, 2010

Drupal 7 is maturing and should have an official release before the end of this year. Once there is an official release support for Drupal 5 will stop. So if you have a Drupal 5 site and haven't upgraded now is the time to do it. And although I have a post about upgrading from Drupal 5 to 6, I didn't really get into upgrading your theme once your site is upgraded. Here are the steps I use to upgrade a Drupal 5 theme.

  • Create a new info file

As of Drupal 6 all themes have an info file, below are the required items.

name = Theme Name
description = One sentence description of theme.
core = 6.x
engine = phptemplate

You should define your stylesheets, JS files, screenshot, features (logo, site name, search, etc) within your info file as well. Also, hook_regions has been deprecated and all regions are now defined in the info.

  • Change regions, variable names, and functions

Modify regions in your page.tpl.php file from $sidebar_left to $left and $sidebar_right to $right. Replace <?php print $layout; ?> with <?php print $body_classes; ?>. $body_classes give you the state of the layout (front logged-in node-type-page no-sidebar). Changing this might impact your CSS, but a simple find and replace will fix things. Remove any function that is related to the $layout variable from the template.php file. Delete the themename_regions function from your template.php file (Regions are now degined in the new info file)

  • Update the html tag for language code support

You can change every instance of $language to $language->language, but I usually just copy this from a core theme. If you don't update this your theme will throw an error.

  • Comment out your entire template.php

If you theme has tons of overrides it might conflict with Drupal 6, so to get the theme up and running you can just comment out all your overrides. You can add them back one at a time that way can isolate any issues or troubleshoot any problems (Use devel).

Optional

  • Add new $signatures variable to comment.tpl.php
  • Add additional variables in Drupal 6.x, look into the preprocess documentation.
  • Define Custom theme settings

And that's pretty much it, after this your theme may require some more CSS love but most of the heavy lifting will be done.

Resources:

Post new comment

  • Allowed HTML tags: <em> <strong> <cite> <code> <ul> <ol> <li>
  • Lines and paragraphs break automatically.

More information about formatting options

By submitting this form, you accept the Mollom privacy policy.

Ishmael Sanchez