1)); // // Database setup for LinksDB information // $old_db = mysql_connect($old_db_host, $old_db_user, $old_db_pass); if (!$old_db) { die('Could not connect to ' . $old_db_host . ' as ' . $old_db_user . ': ' . mysql_error()); } $status = mysql_select_db($old_db_name, $old_db); if (!$status) { die ('Can\'t use ' . $old_db_name .': ' . mysql_error()); } // // Create a new vocabulary for links // $vocabulary = array( 'name' => 'Links Directory', 'multiple' => 1, 'required' => 0, 'hierarchy' => 1, 'relations' => 0, 'weight' => 0, 'nodes' => array('links_directory' => 1), ); taxonomy_save_vocabulary($vocabulary); $vid = $vocabulary['vid']; $category_to_term_map = array( 0 => 0, ); $old_content = mysql_query('SELECT * FROM links_categories', $old_db); while ($link_category = mysql_fetch_array($old_content)) { $edit = array( 'vid' => $vid, 'name' => $link_category['name'], 'parent' => array($category_to_term_map[$link_category['parent']]), ); taxonomy_save_term($edit); $category_to_term_map[$link_category['id']] = $edit['tid']; } // // Load up the links // require_once 'modules/node/node.pages.inc'; $old_links = mysql_query('SELECT * FROM links_links WHERE ACTIVE = 1', $old_db); while ($old_link = mysql_fetch_array($old_links)) { $new_link = array( 'url' => $old_link['url'], 'title' => '', 'attributes' => 'N', ); $tid = $category_to_term_map[$old_link['category']]; $term = taxonomy_get_term($tid); $node = new stdClass(); $node->type = 'directory_link'; // Your specified content type node_object_prepare($node); $node->title = $old_link['name']; $node->field_link_name = array(array('value' => $old_link['name'])); $node->field_link = array($new_link); $node->body = $old_link['description']; $node->taxonomy = array($tid => $term); node_save($node); fwrite($stdout, "Added: " . $node->title . "\n"); }