How to convert posts from Blog Module to "Blog" Custom Content Type?

Events happening in the community are now at Drupal community events on www.drupal.org.
ebrittwebb's picture

I've heard on several occasions, including responses to my last post on How to Segment Blog Personas, the recommendation to NOT use the core blog module, but instead to use CCK and Views to replicate the blog module functionality. This makes perfect sense, and I'm doing that going forward.

But what about a site that already has a bunch of blog posts using the core blog module? Has anyone successfully converted a bunch of existing blog posts from the Blog module to custom content types? Can anyone share step-by-step instructions?

Comments

A long time ago, I used a

skor's picture

A long time ago, I used a direct sql command to change nodes from one type to another, but I can't for the life of me, find that snippet. I had installed the site notes module and was converting my old admin blog posts.

Anyway, while searching for my sql command, I came across this bit of php code that looks easier: http://drupal.org/node/139663#comment-226319

Nodetype module

word

seaneffel's picture

Nodetype is the bees knees. It's really good for switching the node type from one to another, and so long as your blog content type and your new cck content type have identical custom fields, you don't lose anything in transistion from one to the other.

The problem for you is that you may have to either do a bunch manually or attack it at the db level. From what I understand, the Nodetype only changes the type column in the node table, so it shouldn't be difficult to run your own query. The node ID does not change in this process so you don't break any paths.

You can rebuild the blog displays with only three custom views. One for all new blog entries, one with a URL argument based on user to simulate a personal blog display, and one with some custom blocks for most recent and etc. Be sure you don't lose the custom URL path so the transition is seamless for users.

You would have to say good bye or recreate any module that modified the core blog module. Like theme switching for users, author blocks, etc. That could be a pain.

Good luck.

There is also Node Convert I

kellyharding@drupal.org's picture

There is also Node Convert

I tried it on a sandbox dev site I set up to try making CCK + Views blog rather than using the blog module.

Imported a load of blog module nodes from another sandbox I'd been working with, and set up a template to go from Blog (blog module) to Blog Entry (CCK Blog).

All went smoothly.

Hmm...

nancydru's picture

Wow, I get two mentions here.

db_query("UPDATE {node} SET type = '%s' WHERE type = '%s'", $new_type, $old_type)

I have done a pretty large site with almost 300 bloggers and had no trouble separating the personas using the core blog module. And they were grouped using the User Term module. Check http://blogs.forrester.com. You can see the grouping in the right sidebar and on the lower levels you will see the personas. Piece of cake. I don't see a need for CCK here.

Thanks for the snippet Nancy,

twooten's picture

Thanks for the snippet Nancy, worked great! For anyone needing a little more detail, here are the steps I took to convert all my blog posts to my CCK content type called "scoop".

First thing I did was create two new views. I just basically wanted a listing of all my blog nodes so I could see what I had to convert. I made a quick page view in table format that listed the node title and the node type. For the first view I filtered by node type = "blog" to list all the blog nodes. I then cloned that view and changed the filter to show only nodes of type "scoop". Now I could go to those view pages and see what I had to work with. These views were only for convenience and you do not need them. I deleted them after the conversion.

Next I created a new page and called it 'Convert to Scoop'. I put the following into the body field and set the input format to php.

<?php
  $new_type
= 'scoop';
 
$old_type = 'blog';
 
db_query("UPDATE {node} SET type = '%s' WHERE type = '%s'", $new_type, $old_type)
?>

As soon as you save that page the conversion will happen. I refreshed my views pages again and saw that now there were no more nodes of type "blog". I checked the other view that listed "scoop" nodes and sure enough, all the old blog nodes now were listed as "scoop" nodes.

After that I deleted the "Convert to Scoop" page because I wouldn't need that anymore.

Cool!
Tim

Boston

Group categories

More Specifically

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: