Converting a Drupal 5.x theme to 6.x

1) Create an .info file

Create a file in your theme directory, which should look something like this:

name = Human-Readable Theme Name
description = One sentence description of theme.
core = 6.x
engine = phptemplate
The core variable should match the value of DRUPAL_CORE_COMPATIBILITY which is defined in modules/system/system.module

2) Get Drupal to notice the theme

If you create the .info file after running update.php, Drupal will not immediately notice that it has been created. Visit admin/build/themes to refresh.

3) Replace variables

Make sure that none of your variables are named $left, $right, or $footer, and then make the following replacements:

  1. $sidebar_left has become $left
  2. $sidebar_right has become $right
  3. $footer_message has become $footer, but when you output it, it should be echo $footer_message . $footer
  4. $language has become $language->language
  5. If you were using $base_path as a link to the front page, you can now use $front_page instead (which contains url(NULL))
  6. if ($messages) { print $messages; } has become if ($show_messages && $messages) { print $messages; }

4) Add $signature to comment.tpl.php

Add an echo $signature; after $content is output. The Drupal Handbook also provides a way to avoid double printing signatures on comments created in 5.x and before.

5) Get rid of _phptemplate_callback() if you use it

It is no longer supported.

6) (Optional) Replace theme_some_thing() with some-thing.tpl.php

If your theme's template file defines any mytheme_something() or phptemplate_something() functions, you can optionally remove each of those functions and put its content in a separate .tpl.php file in your theme's directory or any subdirectory thereof. (I think. Still looking into this)

A note about clearing/rebuilding the theme registry

You need to rebuild the theme registry every time a .tpl.php file is created, removed, moved or renamed. You do not need to rebuild the theme registry if the contents of a .tpl.php file changes. To rebuild/clear the theme registry (Drupal 6.0) simply visit or reload the modules page admin/build/modules

7) (Optional) Take advantage of new functionality


This guideline is extremely useful, thorough, and well-organized.

Thank you verrry much for putting this up.

if i wanted to, for example, convert the spreadfirefox theme to d6, could i simply do a global find and replace based on what you've described above, copy and paste your code for .info (but call it spreadfirefox) and then just upload and it would work? it seems like there's so much more to this...

Great work !!!

Very helpful

Thanks for this really short but useful "recipe".

Thanks very much for this page, just an extra note for those who have issues with primary links now showing up after updating. In your pages template file you will have a line like ' print theme('menu_links', $primary_links, ' ... To make it work under 6.x all you have to do is change 'menu_links' to 'links'. Hopefully this helps some one like this page helped me.

Spot on ;)

themename_comment($comment, $links = array())

should be redefined to themename_comment($comment, $node, $links = array())

it took me a few days to figure this out.

the line who is respondsable for this is line 1580 in comment.module.
the line content:"$output .= theme('comment', $comment, $node, $links);"

I wonder why the comment module still makes a call to theme('comment'...

there is actually no more theme_comment defined in drupal6.

probably I miss something. :(

Thanks! This really bailed me out.

Thank you very much! This has been a great help for me!

My Aberdeen theme is almost perfect now with Drupal 6.x, just one thing, I'm using Aberdeen-liquid (resizable) and when I select it in Drupal 6.x all of my Website "things" appear in other site, I mean, header OK, left bar OK, but primary links in the footer (instead of in the header), the page content below the primary links (I have to make scroll to see the content...). It seems like the regions had a different size and the header and/or the left bar were displacing the rest of regions.
Any of you imagines what could be happening?

Thank you very much again.

This saved me so much time and effort. I really appreciate you posting this. Thanks!

Great tutorial, it works fine on my blog and saves so much time.

It really isn't necessary. It's not the themes job of calling theme_page or theme_maintenance_page. Only intercepting and overriding, not invoking it where it matters.

Great post! Very helpful!

Thanks a lot!!!

if ($messages) print $messages; has become if ($show_messages && $messages) print $messages;

Should be

if ($messages) print $messages; has become if ($show_messages && $messages): print $messages;

Not a huge mistake, but does break the page.

Actually, if you really want to be precise about this it should be:

if ($show_messages && $messages): print $messages; endif;

Thanks a lot for this post, it it both concise and incredibly helpful for updating custom themes.

This was a huuuge help!! I was dying inside :p. Thank you so very much.

Excellent guide, you cut lots of worry out of the process. Two notes: (1) In my experience admin/build/modules does not clear the registry, but admin/build/themes does. (2) For anyone with CCK fields, you may find that one or more of your fields are failing to display after upgrading. The problem has nothing to do with theming or variable names (although I wasted an hour figuring that out). Just configure your fields again (under admin/content/types). You don't need to change anything if you have the right CCK sub-modules installed; just open it and save it again.

thanks a ton for posting such a precise summary. This made the job so much easier.

Nice how-to.

You should mention that phptemplate_variables() do not work anymore and phptemplate_preprocess() is needed in D6.

Thanks for this guide.

I have several issues though. I'm trying to convert Nifty Corners theme that was made for 5.x to 6.x

The original creator did not include a comment.tpl.php file. Also after I've set to use the theme the menu bar doesn't show up anymore. Any ideas on what I'm doing wrong?


You saved me from a long-long night. Excellent post



Thanks you for this post, it it both concise and incredibly helpful for updating custom themes.

Subscribe to All Posts - Wesley Tanaka