I have moved my Drupal 6 blog into Drupal 7 and migrated all the content including static pages, blog posts and images. For the migration I used the migrate module. I found it very powerful.
Also as a big fan of Twitter Bootstrap, the template was based on it making the mobile as the primary platform. The idea on the main page is that I can replace the background image with my latest best photography. I’m not an expert, but sometimes my photos are very scenic.
The migrate module is designed to migrate content into Drupal from various sources and has Oracle, MsSQL, CSV connectors as well as Drupal 6 with nice examples. The best feature is the dependency management. If an entity is referencing to an other entity, then I can define this dependency in the migration class and the module will handle it.
In order to import the categories, I need to register the migration with a hook, like mymodule_register_migrations. Replace the mymodule with the proper name of your custom module.
I will reuse $common_arguments, so the effective code is much smaller for the whole registration.
In order to import image fields from Drupal 6, there are many ways to success, I choose to import the images first, then make a dependency on the images from node fields rather than import the images with the nodes.
And so on, I’m not going to share the whole source code, but the documentation is really good and the source code of the module is very handy. As you can see, I have imported the two field separatedly. migrate_d2d by default is trying to import everything and for such reason, I had to extend the SQL query generator to filter the field results to only one image field. This can be done easily:
Because of this, the node import is going to be more tricky, but I saved some development time on importing the images once. Let’s see the blogpost import class:
The trick is that I need to tell the field it will import a FileFid instead of a FileName and also, there are some more logic to fill in the Tags field with a comma separated value, extracted from the Drupal 6 tables. Remember, I have already created the Terms as the blogposts are depending from them.