Page content

Migrating (not updating) comments (or other core types) from Drupal 6 to Drupal 7


Introduction

In the process of rebuilding my site, I decided to build from scratch, rather than attempting to upgrade my installation. With my old installation, I had tried out multiple modules, changed themes multiple times, and played around with the database when I didn't fully know what I was doing, leaving me with a system that worked, but at times was buggy. For this reason, I thought it better to build fresh and import.

As such, I needed to import the comments from my Drupal 6 installation to my new Drupal 7 installation. This is easier said than done - comments have received a major restructuring, and use different database tables in Drupal 6 than they did in Drupal 7, and the column names the comment system uses has also changed.

Calling a function after an #AHAH event (Drupal 6)


In Drupal 6, I've at times in the past needed to fire off a function after an AHAH callback. The problem here is that AHAH is a pre-built set of functions by Drupal, and as far as I can tell, the only function it executes after completion is Drupal.behaviors. However, I personally don't see anything in the Drupal object to differentiate whether Drupal.behaviors is being fired on initial page load, or after an AHAH event. jQuery to the rescue! jQuery offers a nice little .ajaxComplete() function that is fired off after every Ajax event. We can use this function to fire off whatever other function we want when AHAH is complete.

Themeing Drupal 6 forms into tables with checkboxes


This tutorial is for Drupal 6. The Drupal 7 tutorial is here: Themeing Drupal 7 forms into tables with checkboxes or radios.

Turning forms into a table of information, such as can be seen on the users administration page (admin/user/user) or the content administration page (admin/content/node) is not the easiest process in Drupal 6. Even looking at the code that is used to create these pages, it can be hard to see what exactly is going on. So lets take a look at how to do this.

First, let's look at our final goal. Drupal comes bundled with a nice little function for creating tables, theme_table(). This function requires two arguments: $header, an array containing the header cell elements of the table, and $rows, and array containing all the data (cells) of the table. $rows is actually a multi-dimensional array, with the top level being the rows, then and the next level being the cells of the row.

Our goal is to build these arrays. In this tutorial, I will be putting together a nice little table that looks like the following:

| ❏ | First Name | Last Name
------------------------------
| ❏ | Indiana | Jones
| ❏ | Darth | Vader
| ❏ | Super | Man