Hi Folks. I'm learning Drupal and I want to export my Drupal-based blog into Moveable Type's simple text format [1]. I found a PHP script that's supposed to do this (simplified version below [2]), but the output is incomplete. First, it's not picking up all blog comments. There are 2,281 of them (SELECT * FROM comments;) but only 4 ("XXX") have comments (see "bug: should be non-zero for all" below).

What the heck's going on? I'd really appreciate any help on this - it's taken some painful learning of DB tables, hooks, and PHP to get to this point...

Thanks a bunch,

matt (matt@matthewcornell.org)

[1] http://www.sixapart.com/movabletype/docs/mtimport

[2] http://andrew.sterling.hanenkamp.com/2008/03/drupal-to-movable-type.html

[3] I run this by creating a new post, pasting the code into the body, setting the Input format to PHP code, and Previewing:

header('Content-type: text/plain');
$nids = db_query("select distinct n.nid from {node} n where type = 'blog'");
while ($node = node_load(db_fetch_object($nids))) {
  print "TITLE: ".$node->title."\n";
  print "DATE: ".strftime("%m/%d/%Y %I:%M:%S %p", $node->created)."\n";
  print "-----\n";
  $comments = db_query("select * from {comments} c where c.nid = %d", $node->nid);
  while ($theComment = db_fetch_object($comments)) {
    print "-----\n";
    print "COMMENT:\n";
    print "SUBJECT: ".$theComment->subject."\n";
    print "DATE: ".strftime("%m/%d/%Y %I:%M:%S %p", $theComment->timestamp)."\n";
    $text = $theComment->comment."\n";
    if ($text != 0)		       // bug: should be non-zero for all
      print "XXX".$text."\n";
  }
  print "--------\n";
 }
exit;

--
Matthew Cornell | matt@matthewcornell.org | 413-626-3621 | 34 Dickinson Street, Amherst MA 01002 | matthewcornell.org