Converting RightFields to CustomFields, Now with SQL Goodness!

Back in December, I put together a script for converting RightFields data to CustomFields. This was mostly for me, but I had a few people request this sort of thing, and I had grown tired of doing it by hand, since I’m inherently lazy. There were two problems with this script. The first was that it didn’t do data stored in custom SQL datasources. Unfortunately it was just too hard to figure out. That’s not to say that I couldn’t make it work, but I wasn’t able to do it in an automated fashion.

The second problem was that it left out a few people who had some data that they might want: Namely those with data stored in file fields (usually a file name, such as that you might use for an image). These fields can be somewhat complex, but if it’s just a name, then it’s not typically a problem in converting the data. So it may be okay to convert it. Still, you should probably be aware that a one-to-one conversion of this sort does have some potential pitfalls. The most common was that CustomFields doesn’t have an upload option, but you also can’t do things like extra file path information. So if you decide you want to convert the filename, you should be aware of these potential downfalls. It’s better than nothing, however.

A couple of weeks ago, Jesse mentioned that he has some clients stuck on RightFields. Since he wasn’t really concerned about the SQL problem, I whipped him up a version that just allowed the conversion of the file data to a standard one-line text field. So far as I know, that one works, but I haven’t heard back (Jesse?). As long as he wasn’t using any of the fancy formatting rules, it shouldn’t be a problem.

Then earlier this week, Ryan Pfister put together a modified version of the earlier script to convert his SQL data, which got me thinking about that process again. He eventually posted the script as well (Ryan has also apparently converted to WordPress, too – no word on that, as the last post is on his RightFields SQL conversion).

In any case, since I was again trying to figure out why I couldn’t get the SQL conversion working, I hacked and hacked. I had posted on the forum a while back, but had yet to get a response. So I asked Brad. He’s a busy guy, and I didn’t get a response. So I kept digging. Eventually I gave up. Again. This morning I got up and I tried to figure out why it would keep blowing up. It seemed fine. Until it wasn’t.

Everything was registering, but it wouldn’t read. Kevin did a great job of creating these object, and the install_properties were running – I even thought perhaps the columns needed to be column_defs, but it wasn’t. That process was working fine, as the columns were coming back okay. Then it hit me. I needed to give it a primary_key in the properties too. I did, and suddenly it all just started working. I cleaned it all up and it was off to the races.

Now there is a working implementation of the RF2CF script, which will read your configuration for the fields, whether it is plugindata or SQL. It will transfer your data from either storage method, and convert it into the new meta storage. The only limitation is that it won’t use the linked entry field type, because nothing even remotely related exists in CustomFields. That, and the aforementioned limitation on the transferring of file type fields. Other than that, you should be set, so enjoy it.

This plugin is not supported, but I’ve pretty well tested it out, so you shouldn’t have any problems.

You do need to use the latest version of RightFields, as there is a modification to it to make this work. If you use your existing code, it will not work. The code with the change is included with the plugin. If you have RightFields installed on your MT4 installation, remove it and only use the version included with this plugin. Just download the new version of the plugin and unpack it to the plugins directory of your installation. Once you do, go to the plugins page of each blog in your installation and follow the three-step process.

Step 1 is to transfer the configuration. Then verify the configuration – this makes sure that you have the correct fields ready for the values that will come over. You should only run this step once. Running it more than once will create duplicate fields in your blog.

Step 2 is to transfer the actual data. You can re-run this step as many times as you like. If you have a lot of records, this step might seem like it’s running for a while without doing anything. Because of the way that the web works, there is little way around this – it has to complete before it shows anything. If anyone wants to help rewrite this to show results as they are processed, let me know and I’ll put it in there.

Step 3 is to modify your templates by getting rid of the RightFields code and replacing it with corresponding CustomFields code. Unfortunately this isn’t really able to be automated, because there are so many variations to the process. If you need help with it, let me know – I do offer Movable Type Consulting (this isn’t a free service, but it may be able to help you out).




7 responses to “Converting RightFields to CustomFields, Now with SQL Goodness!”

  1. Nik Avatar

    Forgive my confusion, but does this convert MT RightFields to WordPress Custom Fields? Or is it converting MT Rightfields to MT Custom Fields?

  2. Chad Everett Avatar

    Hey Ryan –

    No worries, thanks for the clarification. I also noticed you did some work for Citigroup and Merrill Lynch. Anything we ought to know? 🙂

  3. Ryan Pfister Avatar

    Hi Chad-
    I use WordPress for my personal site. I did the RightFields conversion for another Web site I was working on that uses MT. Thanks for the link!

  4. Chad Everett Avatar

    Hmmm –

    4.2: Can’t say for certain, as it’s been tested lightly at best. But it should be fine, because it’s using internal functions, so hopefully they have been updated to work correctly (these are written by 6A at this point, not me). Just make sure you back up first!).

    RF: I’d update to the latest version possible, though I don’t know that it matters. I know I did. That said, I think that the “latest version” wasn’t updated for quite a while.

  5. salguod Avatar

    I’m (finally) ready to upgrade and I have a couple of questions:

    1 – Has this been tested for MT 4.2? Is there any reason it wouldn’t work in 4.2?

    2 – Do I need to update RF in MT 3.33 before upgrading?

    Thanks for doing this, it means I can continue to use MT.

  6. Chad Everett Avatar

    Hey Jesse –

    Glad that it worked for you!

  7. Jesse Gardner Avatar

    Just wanted to say that this plugin was a life saver. I just used it while upgrading Simply Recipes running MT 3.x with RightFields to MTCS with CustomFields. Thanks ever so much!