Handle book structure

artatac - October 11, 2009 - 12:47
Project:Node Export
Version:6.x-2.9
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:active
Description

I created a new book called 'All Fruit@ and then created a child page called 'Apple green'. When I then exported it to another drupal site it worked apart from reversing the book structure. which is wrongly now

Apple green is good
--All Fruit

See export file below

array(
  array(
    'nid' => '35',
    'type' => 'book',
    'language' => '',
    'uid' => '1',
    'status' => '1',
    'created' => '1255262677',
    'changed' => '1255262677',
    'comment' => '2',
    'promote' => '0',
    'moderate' => '0',
    'sticky' => '0',
    'tnid' => '0',
    'translate' => '0',
    'vid' => '35',
    'revision_uid' => '1',
    'title' => 'Apple green is good ',
    'body' => 'Apple green is good Apple green is good Apple green is good Apple green is good Apple green is good Apple green is good Apple green is good Apple green is good Apple green is good Apple green is good Apple green is good Apple green is good Apple green is good Apple green is good Apple green is good Apple green is good Apple green is good Apple green is good Apple green is good Apple green is good Apple green is good Apple green is good Apple green is good Apple green is good Apple green is good Apple green is good Apple green is good

Apple green is good Apple green is good Apple green is good Apple green is good Apple green is good Apple green is good Apple green is good Apple green is good Apple green is good Apple green is good Apple green is good Apple green is good Apple green is good Apple green is good Apple green is good Apple green is good Apple green is good Apple green is good Apple green is good Apple green is good Apple green is good Apple green is good Apple green is good Apple green is good Apple green is good ',
    'teaser' => 'Apple green is good Apple green is good Apple green is good Apple green is good Apple green is good Apple green is good Apple green is good Apple green is good Apple green is good Apple green is good Apple green is good Apple green is good Apple green is good Apple green is good Apple green is good Apple green is good Apple green is good Apple green is good Apple green is good Apple green is good Apple green is good Apple green is good Apple green is good Apple green is good Apple green is good Apple green is good Apple green is good

',
    'log' => '',
    'revision_timestamp' => '1255262677',
    'format' => '1',
    'name' => 'webmaster',
    'picture' => '',
    'data' => 'a:1:{s:13:\"form_build_id\";s:37:\"form-78fa815e174ba0184b2cfe5ee19028de\";}',
    'field_image_cache' => array(
      '0' => array(
        'fid' => NULL,
        'list' => '1',
        'data' => array(
          'description' => '',
          'alt' => '',
          'title' => '',
        ),
        'alt' => '',
        'title' => '',
        'uid' => '1',
        'filename' => 'applegreen.jpg',
        'filepath' => '#FILES_DIRECTORY_PATH#/applegreen.jpg',
        'filemime' => 'image/jpeg',
        'filesize' => '15385',
        'status' => 1,
        'timestamp' => '1255262642',
        'filefield_upload' => 'Upload',
        'filefield_remove' => 'Remove',
        'upload' => '',
        'node_export_file_path' => 'sites/default/files/applegreen.jpg',
      ),
    ),
    'path' => 'apple-green-good',
    'book' => array(
      'mlid' => '826',
      'nid' => '35',
      'bid' => '34',
      'menu_name' => 'book-toc-34',
      'plid' => '825',
      'link_path' => 'node/35',
      'router_path' => 'node/%',
      'link_title' => 'Apple green is good ',
      'options' => array(),
      'module' => 'book',
      'hidden' => '0',
      'external' => '0',
      'has_children' => '0',
      'expanded' => '0',
      'weight' => '0',
      'depth' => '2',
      'customized' => '0',
      'p1' => '825',
      'p2' => '826',
      'p3' => '0',
      'p4' => '0',
      'p5' => '0',
      'p6' => '0',
      'p7' => '0',
      'p8' => '0',
      'p9' => '0',
      'updated' => '0',
      'href' => 'node/35',
      'title' => 'Apple green is good ',
    ),
    'last_comment_timestamp' => '1255262677',
    'last_comment_name' => NULL,
    'comment_count' => '0',
    'taxonomy' => array(
      'tags' => array(
        '2' => 'Apple',
      ),
    ),
    'menu' => array(
      'link_title' => '',
      'mlid' => 0,
      'plid' => 0,
      'menu_name' => 'primary-links',
      'weight' => 0,
      'options' => array(),
      'module' => 'menu',
      'expanded' => 0,
      'hidden' => 0,
      'has_children' => 0,
      'customized' => 0,
      'parent_depth_limit' => 8,
    ),
    '#_export_node_encode_object' => '1',
  ),
  array(
    'nid' => '34',
    'type' => 'story',
    'language' => '',
    'uid' => '1',
    'status' => '1',
    'created' => '1255262556',
    'changed' => '1255262605',
    'comment' => '0',
    'promote' => '0',
    'moderate' => '0',
    'sticky' => '0',
    'tnid' => '0',
    'translate' => '0',
    'vid' => '34',
    'revision_uid' => '1',
    'title' => 'All Fruit ',
    'body' => 'All Fruit text here All Fruit text here All Fruit text here All Fruit text here All Fruit text here All Fruit text here All Fruit text here All Fruit text here All Fruit text here All Fruit text here All Fruit text here All Fruit text here All Fruit text here All Fruit text here All Fruit text here All Fruit text here All Fruit text here All Fruit text here All Fruit text here All Fruit text here All Fruit text here All Fruit text here All Fruit text here All Fruit text here All Fruit text here All Fruit text here All Fruit text here All Fruit text here All Fruit text here All Fruit text here All Fruit text here All Fruit text here All Fruit text here All Fruit text here All Fruit text here

All Fruit text here All Fruit text here All Fruit text here All Fruit text here All Fruit text here All Fruit text here All Fruit text here All Fruit text here All Fruit text here All Fruit text here All Fruit text here All Fruit text here All Fruit text here All Fruit text here All Fruit text here All Fruit text here All Fruit text here All Fruit text here All Fruit text here All Fruit text here All Fruit text here All Fruit text here ',
    'teaser' => 'All Fruit text here All Fruit text here All Fruit text here All Fruit text here All Fruit text here All Fruit text here All Fruit text here All Fruit text here All Fruit text here All Fruit text here All Fruit text here All Fruit text here All Fruit text here All Fruit text here All Fruit text here All Fruit text here All Fruit text here All Fruit text here All Fruit text here All Fruit text here All Fruit text here All Fruit text here All Fruit text here All Fruit text here All Fruit text here All Fruit text here All Fruit text here All Fruit text here All Fruit text here All Fruit text here ',
    'log' => '',
    'revision_timestamp' => '1255262605',
    'format' => '1',
    'name' => 'webmaster',
    'picture' => '',
    'data' => 'a:1:{s:13:\"form_build_id\";s:37:\"form-78fa815e174ba0184b2cfe5ee19028de\";}',
    'field_video' => array(
      '0' => array(
        'embed' => NULL,
        'value' => NULL,
        'provider' => NULL,
        'data' => array(),
      ),
    ),
    'field_image_cache' => array(
      '0' => array(
        'fid' => NULL,
        'list' => '1',
        'data' => array(
          'description' => '',
          'alt' => '',
          'title' => '',
        ),
        'uid' => '1',
        'filename' => 'all_fruit.jpg',
        'filepath' => '#FILES_DIRECTORY_PATH#/all_fruit.jpg',
        'filemime' => 'image/jpeg',
        'filesize' => '15888',
        'status' => '1',
        'timestamp' => '1255262578',
        'node_export_file_path' => 'sites/default/files/all_fruit.jpg',
      ),
    ),
    'path' => 'all-fruit',
    'book' => array(
      'mlid' => '825',
      'nid' => '34',
      'bid' => '34',
      'menu_name' => 'book-toc-34',
      'plid' => '0',
      'link_path' => 'node/34',
      'router_path' => 'node/%',
      'link_title' => 'All Fruit ',
      'options' => array(),
      'module' => 'book',
      'hidden' => '0',
      'external' => '0',
      'has_children' => '1',
      'expanded' => '0',
      'weight' => '0',
      'depth' => '1',
      'customized' => '0',
      'p1' => '825',
      'p2' => '0',
      'p3' => '0',
      'p4' => '0',
      'p5' => '0',
      'p6' => '0',
      'p7' => '0',
      'p8' => '0',
      'p9' => '0',
      'updated' => '0',
      'href' => 'node/34',
      'title' => 'All Fruit ',
    ),
    'last_comment_timestamp' => '1255262556',
    'last_comment_name' => NULL,
    'comment_count' => '0',
    'taxonomy' => array(
      'tags' => array(
        '2' => 'Fruit',
      ),
    ),
    'menu' => array(
      'link_title' => '',
      'mlid' => 0,
      'plid' => 0,
      'menu_name' => 'primary-links',
      'weight' => 0,
      'options' => array(),
      'module' => 'menu',
      'expanded' => 0,
      'hidden' => 0,
      'has_children' => 0,
      'customized' => 0,
      'parent_depth_limit' => 8,
    ),
    '#_export_node_encode_object' => '1',
  ),
)

#1

danielb - October 12, 2009 - 00:04
Status:active» closed

Books are not preserved. This module is designed to export nodes, not books.

#2

artatac - October 12, 2009 - 12:43

Thanks Daniel - I did read that, and could understand it not exporting book info, but why in that case does it export it wrongly. Better to loose all the book structure info and recreate it that have to undo the wrong info. Also if it does invert the structure perhaps the code could be tweaked to either ignore this info or make it export the correct way round - just a thought

#3

danielb - October 13, 2009 - 00:07
Title:Reverse book structure» Handle book structure
Category:bug report» feature request
Status:closed» active

I'm not sure why it's reversing the book structure - could be a fluke that the nids are swapped around. Either way there is nothing handling the book information during import. The more I think of it, I guess it wouldn't be that hard to write a bit of logic to check for this first, and since book.module is in core this is a legit feature request.

PS. In the latest versions of this module you can there is a config option to remove some of the book structure info from the export codes.

#4

artatac - October 13, 2009 - 06:42

Thanks Daniel

I will try and reproduce this and give you access to it so we can understand if this is always doing the same thing

#5

artatac - October 13, 2009 - 09:33

Hi Daniel
I have worked out what is happening. I created a fresh drupal install > added node_export > and enabled book module. I then duplicated the empty site. In site B I created 3 book nodes with a book structure of:
Fruit intro page
--Red apple page
----Toffee apples are great
I then exported them and pasted them into (empty) site A > and the book pages got messed up. I checked to import text and it seemed fine so I then reexported these pages and compared the 2 text files (see attached pdf). The bottom line is that node export text file gathers the nodes from the newest to the oldest. In my simple case this is

toffee apple (node id 3)
Red apple (node id 2)
Fruit intro page (node id 1)

But when you import this into the empty file it ignores the original node id and processes the file from the top ie toffee apple becomes node id 1 etc.

To prove this I manually altered the import file just pasting the text blocks so they became

Fruit intro page (node id 1)
Red apple (node id 2)
toffee apple (node id 3)

Fruit into (the original node id 1) gets processed first and retains its node id 1 etc AND retains its correct book structure

For those who are not looking to try and preserve the node ids having the export file ordered oldest to newest would make no difference but for those who would value it matching it would be a great help

If you need more info let me know - regards

Joe

AttachmentSize
nodeexport.pdf 21.93 KB

#6

artatac - October 17, 2009 - 07:36

Hi Daniel
could I request the reversing node order as described above as a feature request please. If you need any extra info let me know - thanks Joe

#7

danielb - October 18, 2009 - 01:03

The only way to solve this is to handle book structures completely. Reversing the nids just happens to fix your test case import - but it will not work in all cases.

#8

artatac - October 19, 2009 - 11:00

good point - all I can do then is request that book handling be considered as a future feature please

Thanks

Joe

 
 

Drupal is a registered trademark of Dries Buytaert.