I am using Drupal 6. I have an external database that I need to somehow turn into nodes so that our Drupal site can display the content and search the content with Solr. I currently have a module which displays pages and queries the database directly each time these pages are viewed. This is not an optimal solution because these pages are not found when a user uses our search.
I know that I can iterate through the database items, create a $node object and use node_save() to create nodes.
1) Can I set a specific NID such as $node->nid = 9999999 . $some_database_key so that I know these nodes can be referenced later for updating?
I could not get this to work, but I did figure out this solution: I created a database table for my module similar to the one in the node_example module. Using this and a custom content type, I could create nodes. I could not get it to work properly until I used
$node = node_submit($node);
prior to calling
node_save($node);
2) How do I create menu items for these new nodes?
Solution
$link = array();
$link['menu_name'] = 'custom_menu'; // Fill out your menu name or just use navigation
$link['link_title'] = 'Title Here'; // What appears in the menu link
$link['link_path'] = 'node/' . $node->nid; // Or you can use a path alias as well
$link['plid'] = 12; // Optional - if you want it to nest under an item you'll need its mlid (menu id)
menu_link_save($link);
See: http://api.drupal.org/api/drupal/includes--menu.inc/function/menu_link_save/6
3) How do I create aliases for these nodes such as node/856 goes to programs/some-program-type/some-program-title
SOLUTION Similar to the menu solution above, you can use
path_set_alias('node/' . $node->nid, 'path/alias/here');
Thanks for any suggestions!