2012-05-12 31 views
0

我需要將一本書(某種手冊)從expressionengine網站遷移到drupal 7.我將使用核心書籍模塊將本書放入。由於這是一次性導入我使用了一個基於這個簡單的自定義導入腳本:http://www.group42.ca/creating_and_updating_nodes_programmatically_in_drupal_7。 我希望能夠設置每個書頁的父ID,但我無法找到如何做到這一點。我已經嘗試了一些直觀的東西像drupal 7 import book set parent/book id

`$node->pid = $parentId;` 

和其他...

但是我完全失去了,我應該找上api.drupal.org此信息。任何人都可以將我指向正確的方向?

我不知道你是否還需要設置書此頁明確,或者設置一個家長就足夠了...

感謝,

里斯

回答

0

Sergey Litvinenko指出代碼的重要部分

<?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);