Porting Drupal 5 themes to Drupal 6

Introduction

Due to the basic installation of Drupal, which is running this website, I'll dedicate my first(!) post to the latest outcome of the Drupal community -Drupal 6-

Besides some new core features like "trigger", Drupal 6 comes with a new themeing function which seems, at first sight, a bit confusing. But let's have a look at that...I assume that you've already messed around with Drupal and "the themeing thingy" (Yes, Drupal says "themEing")


IF NOT, STOP READING HERE and CLICK


Here we go

If you've successfully conquered the first barrier we can go on straight forward. At first I would like to recommend you to download the lastest release of Drupal (get it here).
As soon as you have successfully untared/unzipped the file have a look at a core theme like "Garland" (you can find the page.tpl.php in: drupal/themes/Garland/page.tpl.php). At first sight there seems to be no difference between the older files of Drupal 5 and the one you're just looking at...but there are differences

If you are upgrading your theme from versions before Drupal 6 and the region variables of $sidebar_left and $sidebar_right were used, rename them to $left and $right.

Although the $footer_message region variable in versions before 6 mixed the footer region with the footer message (set from "Administer > Site configuration > Site information"). Make sure a separate $footer variable is created if your theme uses it since Drupal 6 and above no longer combines the two elements.

As for the pure "page.tpl.php" thing we've already discovered the slight but important changes. (I mean(!) important because it took me a while and some coffe, wondering where my sidebars are...)

Part II

Okay, if you got the the time - edit your favourite Drupal 5 theme and copy it into your Drupal 6 theme folder and read on.

If not, I can tell you what happens next. Exactly NOTHING. Why? Because we've just discovered the second developement of Drupal6. The .info file:


»New to Drupal 6, .info configuration files are now required for each theme. This file should reside in your theme's directory. Without this file, your theme will not be visible by Drupal. The .info file must end with the ".info" extension. The internal "machine" readable name of the theme is derived from this file. For example, if it is named "drop.info", then Drupal will see the name of the theme as "drop". Be sure that no odd characters are used since it informs Drupal on how to form various functions in PHP and therefore it will have the same limitations. The name should start with an alphabetic character, no spaces or punctuation. Underscores are allowed but no hyphens. Numbers are allowed as long as it is not the first character.« -drupal.org


Um, sounds needless...but there are some nice advantages. You can change the behaviour and look & feel of your website with the info file i.e. like that:



»Traditionally, themes default to using style.css automatically and could add additional stylesheets by calling drupal_add_css() in their template.php file. Starting in 6, themes can also add style sheets through their .info file. I.e.stylesheets[all][] = theStyle.css«

Here's a copy of my .info file which works nice with the custom theme you're looking at right now.

As soon as you have uploaded your info file into your themes/mytheme folder, you'll be able to see your theme in the administer section. That's all.


The quick and dirty summary

  • Replace the $sidebar_left with $left
  • Replace the $sidebar_right with $right
  • create a single $footer variable
  • create a info file a copy it into your themes' folder

For further information I recommend the following links:

Drupal info file

Themes & Drupal 6

As usual google is always your friend.

Comments

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code>
  • Lines and paragraphs break automatically.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.