Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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',
),
)
Comments
Comment #1
danielb CreditAttribution: danielb commentedBooks are not preserved. This module is designed to export nodes, not books.
Comment #2
artatac CreditAttribution: artatac commentedThanks 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
Comment #3
danielb CreditAttribution: danielb commentedI'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.
Comment #4
artatac CreditAttribution: artatac commentedThanks 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
Comment #5
artatac CreditAttribution: artatac commentedHi 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
Comment #6
artatac CreditAttribution: artatac commentedHi 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
Comment #7
danielb CreditAttribution: danielb commentedThe 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.
Comment #8
artatac CreditAttribution: artatac commentedgood point - all I can do then is request that book handling be considered as a future feature please
Thanks
Joe
Comment #9
danielb CreditAttribution: danielb commentedComment #10
James Andres CreditAttribution: James Andres commentedHi danielb, this might help the situation. I recently had to deal with many exported book and wrote this helper function to manage them. It needs cleaning up, and still needs the rest of the integration with node_export.
Here's a rough, rather brute force, plan that may work:
The helper function to create book outlines is:
Comment #11
mparker17I also need to be able to export content in books, so I created a module,
node_export_book
, to do that. Attached is the result of my work.I chose to patch the
node_export
module rather than just create a new module because I don't have CVS access yet, I don't have time to maintain a module right now and I figure that, sincebook
is part of core, the ability to export books might as well go withnode_export
itself.I was developing on the HEAD of
node_export-6.x-2.x
; but AFAIK it should work on any 6.x-2.x version ofnode_export
. I did not develop for 6.x-3.x because the HEAD of that branch did not actually work at the time.@James Andres, your
install_book_set_outline()
function was super-useful and saved me a lot of work! Thanks!Disclaimer: CVS apparently doesn't like it when you add files (refuses to generate patches), and I couldn't find any best-practices to get around this (or at least, ones that worked for me), so I ended up using Git to generate the patch instead. Git signifies creating a file by patching nothing (/dev/null) into a file... patching worked fine on my systems (OS/X and Linux), but I can imagine the patch not applying as nicely on non-UNIX systems, which may or may not have a /dev/null.
Comment #12
danielb CreditAttribution: danielb commentedI won't use that patch, because it's against the 2.x, and I don't know if I'll be able to get a git patch to apply. But thanks for your efforts, I will use your patch and James' post as reference when I get around to this.
Comment #13
mparker17I just tried running my patch against 6.x-3.x HEAD. It applies cleanly, but I don't think that one of the hooks is being called: some of the fields that I expect to be in the node code are set to
FALSE
instead of having a UUID (like I expect). I suspect this is because the hook has changed names slightly, but I haven't done enough investigation to be able to say that for certain.I will investigate further and try to generate a patch for 6.x-3.x HEAD.
Comment #14
danielb CreditAttribution: danielb commentedDon't worry about making a new patch, I have another idea on what might work here, and I can always reference your previous patch for clues.
Comment #15
mparker17@danielb: Okay.
Returning issue to previous state.
Comment #16
mparker17I just used my patched module again and discovered that I forgot to mention something important earlier: it only parents the book pages properly if the exported book pages do not contain the `Menu link` information (i.e.: it only works if the node array is missing the
'menu' => ...
sub-array).This is because the Book module uses menu items to build the book structures.
Comment #17
btopro CreditAttribution: btopro commentedis this planned to be in the 3.x version? I'd love to account for this module in the outline designer and allow for a context menu option for 'export node structure'
Comment #18
mparker17@danielb, have you made any progress implementing this in version 3.x?
@btopro approached me through e-mail for some support, and we ended up discussing whether or not it would be good to make a separate
node_export_book
module so that people can take advantage of it right away. It would also save the maintainers ofnode_export
from the trouble of maintainingnode_export_book
. I'm interested in feedback from anyone in the thread — does anyone have any comments about this? Is this a good idea? Would anyone use the module?Comment #19
btopro CreditAttribution: btopro commentedIf not, we can post the poc here for reference. This is a screenshot of the GUI modification provided by the node_export_book module that's been thrown together
Comment #20
danielb CreditAttribution: danielb commentedDevelopment of features on this module will now be focused on 7.x-3.x-dev, with backports possible after fixing.
Comment #21
mparker17I've re-written
node_export_book
for node_export-7.x-3.x. It incorporates the changes to the book administration page GUI that @btopro wrote. Please review the attached patch.Comment #22
mparker17I've changed the patch to be explicit about which versions of node_export and UUID it depends on.
Comment #23
tarzadon CreditAttribution: tarzadon commentedI'm wondering when the D6 backport will be available.
I have to export a book with almost 300 nodes in it. It would be very helpful if I didn't have to manually redo the Book structure after doing the Node export/import.
@mparker17 I would definitely be interested in a separate module that I could use right away. Maybe at least until the D7 version has been backported.
Comment #24
danielb CreditAttribution: danielb commentedDon't change the issue settings.
Comment #25
mparker17@tarzadon: my employer works mostly with not-for-profits and charities, so we don't currently have the budget for me to work on a backport to 6.x-3.x (unless you're willing to hire me through PeaceWorks). I could do the backport in my spare time, but considering that I work 3 jobs, there's no guarantee that I'll be able to get it done in a timely manner.
We currently get around the lack of node_export-6.x-3.x support by:
Comment #26
btopro CreditAttribution: btopro commentedto the person looking for a D6 way of migrating book items... download http://drupal.org/project/elms_features and look for the elms_content_import and elms_content_export features. The exporter can be activated on any drupal site to add a link next to a book outline that says "export". This dumps to an XML file with UUIDs.
elms_content_import sits on the site you want to import into and uses Feeds + Feeds XPath Parser + Feeds Node Helper + UUID modules to import the data correctly on the other side. Probably won't be a direct turn it on and be done (tho both have been run in production to migrate content outlines and import them into OG structures).
I know this isn't a node export type of thing but it is 6.x and could keep this conversation from drifting down the "WE NEED A BACKPORT NOW" road too far.
Comment #27
tarzadon CreditAttribution: tarzadon commented@mparker17 Thanks for your instructions. It worked pretty well! Except now when I edit it a node, there is no parent listed. It's strange. The Book is listed correctly, but the Parent Item is blank.
Comment #28
tarzadon CreditAttribution: tarzadon commentedI think I figured it out. When I imported the book, the book structure was created in menu_links with the menu_name= "primary_links" and module="menu".
I changed all the relevant menu_names to book-toc-[bid] and module = "book"
Now the book doesn't show up in Primary Links and when I edit the nodes, Parent Item is correct.
Comment #29
danielb CreditAttribution: danielb commentedI've been looking into solving this over the last couple days with another technique, which has failed, because the book module friggen sucks. Node are related through menu links... not through node ids... at all.. argh
I'm still thinking about it, I really don't want to maintain a whole another module just for books :(
Comment #30
btopro CreditAttribution: btopro commentedMaybe this would help -- http://drupal.org/project/menu_node optional requirement of this would allow for something with much easier queries for relationability.
For D6 I use http://drupal.org/project/feeds_node_helper + UUIDs in order to make a feed that can read in XML structures and convert the UUIDs to the new node IDs on creation. D7 is untested but would be happy to accept patches to get it working if there are issues (its a machine port).
Comment #31
danielb CreditAttribution: danielb commentedI have a plan that would automatically include all pages of a book anytime any page of a book was exported. All pages at least for now, we could get into the finer logic of it in the future. It would still require custom code specifically for the book module to fix the mlid, but it is a lot less code than node_export_book. The bid fixing would be somewhat automatic (would use the same processes that node reference, etc.. use, hence no new custom code)
Comment #32
danielb CreditAttribution: danielb commentedI've created a module called node_export_dependency which is intended to replace node_export_relation.
It can automatically exports book pages related to any book page being exported, and tracks the information about book dependencies. However it might not completely fix things up upon import, not sure - there is another problem discouraging me from testing this from another issue. I've created a function node_export_dependency_node_export_dependency_alter() where code would go to make any additional fixes required.
When #744758: Handle overwriting, skipping, and nid preservation is fixed it will be a lot clearer how to proceed with this.
Comment #33
danielb CreditAttribution: danielb commentedComment #34
danielb CreditAttribution: danielb commentedYeah definitely needs work, in some configurations it breaks completely, in some it associates to the wrong nodes.
Specifically if resetting the book mlid on the content type vs not, and creating a new node vs creating a new revision.
Comment #35
imp7 CreditAttribution: imp7 commentedI also saw that the wrong parent associates books showed up on an import. Let me know if I can test things for you danielb. Would be amazing to get this functionality, it would save all the node_save etc I am doing manually for books.
Comment #36
danielb CreditAttribution: danielb commentedI've implemented a change to fix the mlid issue, and made it clearer in the settings that when creating duplicate nodes on import the relationships will be maintained to the old nodes. That's still a problem of course, but I haven't worked out how to deal with it.
Anyway more testing still needed.
Comment #37
moonray CreditAttribution: moonray commentedHere's my use case that destroys the books hierarchy:
At this point my top level book node isn't a proper top-level book item anymore, and all it's children have been left with no parent.
The
It seems the book export isn't making use of UUID enough.
Comment #38
moonray CreditAttribution: moonray commentedMore observations:
• Book module keeps track of book nodes through menu links (mlid). However, when Node Export imports an existing node it gives it a new mlid, resulting in multiple menu items. It should delete the old menu if it's going to create a new one (the same goes for regular menu items, btw, but that might have to be addressed in a separate issue). Perhaps an easy way to do it would be calling
book_node_delete($node)
?•
book_node_export_dependency()
outputs the property of a dependency as'property' => array(array('book', 'bid')),
while the rest of the module expects'property' => array('book', 'bid'),
. Either the rest of the module needs to be fixed, or this function.•
node_export_dependency_handle_dependency()
usesif (isset($disabled_modules[$dependency['module']])) {
to check for disabled modules when it should really useif (!empty($disabled_modules[$dependency['module']])) {
. The disabled_modules array always contains the keys with a value of 0 for not disabled, or the key as the value if disabled.I was trying to come up with a fix, but I don't have the time to delve into this issue much farther, so at least I'll share what I've found so far.
Comment #39
annve CreditAttribution: annve commentedWe 've changed the patch so that the weight of a book page is exported correctly.
Comment #40
danielb CreditAttribution: danielb commentedComment #41
danielb CreditAttribution: danielb commentedComment #42
danielb CreditAttribution: danielb commentedIs this actually causing any problems? The module does in fact expect array(array()), but will accept array() for simplification/backward compatibility.
Comment #43
danielb CreditAttribution: danielb commentedI've made that change now.
This is only the case if your imports create a duplicate node. Supporting dependencies to a duplicated node is not yet supported, as shown in the settings, so I consider that covered for now. Unless I've misunderstood what you mean?
Comment #44
torpy CreditAttribution: torpy commentedPatch from #39 is malformed. Fixed that up and a couple of variable reference errors.
Comment #45
danielb CreditAttribution: danielb commentedIf you guys want to maintain node_export_book, may I suggest starting a sandbox or project for this purpose? You will be able to properly deal with it that way.
Comment #47
bago CreditAttribution: bago commentedThis saved my life!
Unfortunately I had to bring back an old backup in order to repeat the export using this module because the book I exported previously with "book_export" alone missed the structure: this is a big missing thing! Anyone using a book use it for the hierarchy things... the node_export reference book a lot of time and people would expect it to be able to export/import the whole book correctly.
So this module should be included in node_export or at least the module should make it clear that it will loose the hierarchy.
I open it because I don't see yet a separate module and anyway I think something should be at least documented on the main module, so let's use this issue to keep track of this.
Comment #48
bago CreditAttribution: bago commentedComment #49
rooby CreditAttribution: rooby commentedThere definitely should be amessage to say this doesn't work with books.
It even actually says this on the project page:
This says that books are supported, when they are not properly supported.
To the people who have worked on this patch, do any of you want to post and support this as a separate project?
If not I will make a project out of it if it cannot go in this module.
Comment #51
danielb CreditAttribution: danielb commentedOK I added node export book