Moving MangoBlog Database entries to BlogCFC

Ray Camden got asked recently if it is possible to migrate database entries from MangoBlog to BlogCFC.

Ray kindly pointed them to my "Return to BlogCFC" post where I talked about my trials and tribulations of moving from MangoBlog back to BlogCFC.

What I didn't do in that blog post is provide the code that enabled me to actually do the move. Since I was asked for step by step instructions I thought I would post the code I used with a few notes.

So here are the notes :

  • Its CF9 only, as I've used CF ORM functionality to hook into the MangoBlog database, rather than make calls through the MB API.
  • MangoBlog doesn't do enclosures by default, so if anyone has gone from BlogCFC to MB and back again they will lose all their enclosures.
  • If you've got excerpts in MB, then they will be dropped, as I couldn't come up with a good way of making sure that the excerpt wasn't also the first section of the content and insert a [more] tag appropriately.
  • Pages that are disabled on MB will still be copied across to BlogCFC and be displayed as there's no show/hide functionality on BlogCFC pages.
  • It does differentiate between posts and pages and inserts them into blogcfc appropriately
  • This code does take into account the revisions database table and uses the latest revision data to add to blogcfc.

The attached code doesn't move subscribers across, but it wouldn't be difficult to add.

The final output is the number of blog entries posted across into BlogCFC along with dumps of any comments and their posts where comment spam was found.

You need to have a datasource set up for your MangoBlog alongside a working copy of your new BlogCFC blog. You'll need to point the ORM part of the code at your MangoBlog DSN in the Application.cfc and configure the BlogCFC login and page cfc initialisation in the index.cfm.

The only other thing that you will need to do is change the addComment() function in blogcfc.cfc. It needs an argument called "posted". You should default posted to blogNow(). The <cfqueryparam value="#blogNow()#" cfsqltype="CF_SQL_TIMESTAMP"> should be changed to use arguments.posted instead of blogNow(). This change allows you to add comments in with a specific date and time rather than "now", so that the date and time that the comment was originally posted can be maintained.

And that's it really.

The code isn't pretty, because I only wrote it for my own personal use, but it should be easy enough to see what is going on. Also, I haven't tested this code since blogcfc, so it might not work first time. Please do send me any tweaks you have to make to get it working with the latest version of BlogCFC and I'll make sure that the enclosure on this post stays up to date.

Related Blog Entries

Nice, when I get to work today, I'm going to add this to the official FAQ at
# Posted By Raymond Camden | 10/20/10 1:02 PM
Thanks, Nil. It might be useful for me.
# Posted By ppshein | 10/20/10 1:14 PM

Unfortunately, DAO doesn't work on Railo.
# Posted By ppshein | 10/22/10 2:58 AM
You could always try ask the chaps at Railo nicely to get onto this : ;)
# Posted By Stephen Moretti | 10/22/10 9:27 AM
Thanks, nil. I'll try to migrate database this weekend. :)
# Posted By ppshein | 10/22/10 11:23 AM

I've finally migrated to blogCFC. Thanks.
# Posted By ppshein | 10/23/10 10:05 AM
I went through this, with only a few issues related to my Mango setup. But I've noticed some oddities. On the public pages the comments are linked to the entries, but in the admin for each entry clicking the view link takes me to a page stating "Sorry There are no blog entries available that match your criteria.". Any ideas?
# Posted By Rob Barthle | 6/1/11 5:32 AM
I had a couple of oddities with dates, the URLs and the blog titles, which is what immediately comes to mind.

I'd suggest looking at the getentry function in blog cfc and the code in Application. cfm that breaks up the url into bits to find it in the database.
# Posted By Stephen Moretti | 6/1/11 7:24 AM