0
votes

I need to migrate a book (some sort of manual) from an expressionengine website to drupal 7. I will be using the core book module to put the book in. Since this is a one time import I used a simple custom import script based on this one: http://www.group42.ca/creating_and_updating_nodes_programmatically_in_drupal_7. I want to be able to set the parent id of each book page but I can't find how to do this. I already tried some intuitive things like

`$node->pid = $parentId;`

and others...

However I'm totally lost where I should look for this information on api.drupal.org . Anyone can point me in the right direction?

I don't know if you also need to set the book this page to explicitly or if setting a parent is enough...

Thanks,

Joris

2

2 Answers

0
votes

Sergey Litvinenko pointed to important part of code

<?php
define('DRUPAL_ROOT', dirname(__FILE__).'/../../../..');
chdir(DRUPAL_ROOT);

require_once "./includes/bootstrap.inc";
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);

$node = entity_create(
    'node',
    array(
      'type' => 'book_name',
      'title' => 'test',
      'body' => array(
        'und' => array(
          array(
            'value' => 'body text here',
            'format' => 2, // Full html
          ),
        ),
      ),
      'field_name' => ...
    )
);
$node->uid = 2; // user id for author
node_save($node);

// book: 
$node->book['bid'] = 21; // nid of the Top-Level Element or 'new' to create new top Level Book
$node->book['plid'] = 2607; // mlid of the parent book-page from table 'book' in db
_book_update_outline($node);