Moving from Drupal 6 to Drupal 7 - A Themer's Perspective

⚠️ Warning
This post is more than 10 years old. I do not delete posts, because even old information is still useful, but please know that some material on this page may be outdated or incorrect. Thanks!
Nov 18, 2010

The transition from Drupal 6 to Drupal 7 has taken a bit of time, and I (like many others) simply haven't had enough time in the past few months to do D7 testing while in the midst of tens of other D6 projects.

I've committed, though, to building out three Drupal sites in Drupal 7, now that we're at beta-3, and I will be posting a few reflections, mostly from a themer's perspective on some changes—the good, the bad, and the confusing.

A New Default Theme - Bartik

Just like Drupal 5/6's default theme, Garland (which is in use on this site right now :-/), Bartik will be seen on thousands of quickly-built sites around the web, and I think the theme is robust enough for this purpose. I'm actually building one site's theme directly on top of Bartik, just modifying CSS through a single stylesheet added by a custom module.

But it's nothing amazing, in my opinion. I think it would've been awesome to have some sort of dropdown menu support in core by this point—but it looks like that will wait until Drupal 8 at least. This is probably the number one most requested feature I get on a lot of the smaller sites I'm asked to build, and having the feature in core would be über-cool.

API Changes Everywhere

Developers have a large set of API changes that they'll need to discover and learn anew, such as the DBTNG changes, file handling changes, etc... but themers also have a few changes to contend with.

Two quick ones that I encounter on most sites are:

drupal_set_html_head() --> has been changed to drupal_add_html_head()

What used to be a simple "fill in the first argument with the code you'd like to output in the <head> section of your page" has now turned into a somewhat more complicated, but ultimately more flexible and 'hook-into-able' affair. You need to feed the HTML into drupal_add_html_head() as an array. See the docs page linked above for more info (and see, specifically, the comment I added to that page.

drupal_add_css() gets simpler, more complex

In Drupal 6, you could throw a quick CSS file at drupal_add_css(), along with a couple other simple arguments to define what kind of stylesheet they've added. In Drupal 7, you can do all of this, but in a somewhat more robust way. There are some nice new options, like telling drupal you'd like the stylesheet to load for every page, or setting a weight for your CSS so you can have it appear lower in the list (to override other stylesheets, for instance).

Also, you can now call drupal_static_reset('drupal_add_css'); to quickly wipe out all other stylesheets added before yours. This can be nice for debugging purposes, or if you just want to simplify to one stylesheet that you (or your module) provide(s).

These are just two of the functions I interact with on a regular basis that will be a bit different and afford more flexibility. What are some of your favorites / most often used?