I just created book.inc in "supported" folder as follows and it is importing the content as "page"

function book_node_import_types() {
  return array(
    'book' => t('Book'),
  );
}

/**
 * Implementation of hook_node_import_fields().
 */
function book_node_import_fields($type) {
  if ($type == 'book') {
    return array(
      'title' => t('Title'),
      'body' => t('Body'),
         );
  }
}

How i can import the Parent, page title, input format with this. Please guide me

Comments

Robrecht Jacques’s picture

For parent links, look at following example from content.inc:

            case 'nodereference':
              // If $value is numeric use it, otherwise
              // find a node title that matches and get nid.
              if (intval($value) > 0) {
                $value = intval($value);
              }
              else {
                $referenced_nodes = array();
                $sql = "SELECT nid, title FROM {node} WHERE title SOUNDS LIKE '%s'";
                $result = db_query($sql, $value);
                $record_found = db_fetch_object($result);
                if ($record_found) {
                  $value = $record_found->nid;
                }
              }
              break;

Basically you would do the same in book_node_import_prepare(), only to assign the found nid to $node->parent.

So the steps for parent links is:
- add a "node_import_book_parent" => t('Book: Parent link') to book_node_import_fields(),
- in book_node_import_prepare() you lookup the nid for $node->node_import_book_parent similar to the code above and assign it to $node->parent.

I'll look into the body format myself as this is probably needed for page.inc and story.inc too.

I don't understand what you mean by page title. Isn't this just "Title" ?

incom’s picture

Thank you for the update. I mean "Title" is the page_title_module field.

i am not expert in php, however i modified the book.inc as follows and it is wworking and adding the 'parent' to book page.

But to get the teaser, i have to update again even though i assigned 'published, promoted to front page' - please correct/modify the following book.inc and add it in your next update -

<?php
/* $Id: book.inc,v 1.5 2006/09/20 20:55:42 robrechtj Exp $ */

/**
 * Implementation of hook_node_import_types().
 */
function book_node_import_types() {
  return array(
    'book' => t('Book'),
    'node_import_book_parent' => t('Book: Parent link')
  );
}

/**
 * Implementation of hook_node_import_fields().
 */
function book_node_import_fields($type) {
  if ($type == 'book') {
    return array(
      'title' => t('Title'),
      'body' => t('Body'),
      'parent' => t('Parent'),
    );
  }
}
Robrecht Jacques’s picture

Status: Active » Fixed

Fixed in 4.7.x-1.3.

Please open another issue for your problems with published and promoted to front page.
Note that the format used is the default format - I'll work on that for a later release.

Robrecht Jacques’s picture

Support for page_title.module has been added in 4.7.x-1.4.

Anonymous’s picture

Status: Fixed » Closed (fixed)