Flexinode to CCK using Drupal 5.x
As I promised weeks ago, here's how I converted my Flexinode node types to CCK. For my needs, I used a local development box that started out as Drupal 4.7 and was upgraded normally to Drupal 5.x. I did not have Flexinode installed for 5.x - I knew I was migrating so I didn't bother downloading it. I wrote and tested my converter on the dev box, then did the same upgrade steps on the production server, running my converter last. The script assumes knowledge of how Flexinode and CCK database tables were designed, and keeping the URLs exactly the same from node type to node type. I've done similar processes on two sites so far, and am planning a third. This is not an example of the standard "Drupal upgrade process" and it certainly isn't end-user friendly - this will never be any sort of official process, nor would I want it to.
There are a few things you need to know first:
- Do you plan to use the body field of a node? This is a good time to redesign your data if necessary - CCK node types allow you to define (or not) whether a node's body field is used. This becomes particularly nice if you want to CCK a blogapi-enabled node type. If body is not used, we'll be deleting it and teaser during the conversion (Flexinode would pre-create the teaser and body fields on
node_save()
which is not necessary for CCK). - Do you have any odd field types that don't correlate to CCK? You'll need to do some grunt work to see if complicated Flexinode field types are available in CCK. For one of my sites, I used Flexinode's
field_table.inc
to create a 2x3 table that users would enter up to three URLs in along with their titles. This maps nicely to CCK's link.module, though these types of things require special attention in the conversion process. If all you've got are boring textfields and textareas, you're golden. - You'll need to precreate your CCK node type. My conversion process only works on data, NOT the data structure and design. Make your CCK node type, perfect it, test out that it works, then examine the created database tables and rows. Look at the column names, how things correlate to the
node_revisions
table (if at all), and pay close attention to whether a CCK field allows a specific input format. If it's plain text, we won't have to convert that data from Flexinode. If an input format is allowed, we'll have to. - You'll need to know the field IDs of your Flexinode field types. Easiest way to find these out is to head to the Flexinode content type screen, mouse over each of the fields you've added, and jot down the IDs. You can, of course, find these out via the database if you've already upgraded to 5.x and don't have Flexinode installed anymore. I'll leave that up to you.
This example code was created in a custom module for one of my conversions; I'm not showing the entire module framework because I assume you know what you're doing. You can also stick this stuff in a convert.php
with index.php
-like bootstraps. Whatever works. The code contains the rest of the documentation.