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 5.9.5.004, 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.

Unfortunately, DAO doesn't work on Railo.
I've finally migrated to blogCFC. Thanks.
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.