Can anybody point me in the direction of some documentation regarding changes to book.module from Drupal 5.x -> 6.x?

I'm trying to programatically (i.e. at the database level) migrate a large number of books from a 5.x site to the RC3 of Drupal 6, and I've run into some problems regarding the schema changes...

In 5.x, a book page is defined by an entry with type 'book' in the node table, and a corresponding entry in the book table (nid) to define its relationship to a parent page (parent) - if the parent is 0 then it's a top level book. Easy.

However, in 6.x, the book table now contains an nid, bid(?), and mlid(?), and the mlid links to a book-toc-xxx record in the menu_links table... and in the drupal interface itself, I notice that at node/add/book I can no longer simply select a parent book page, but I have to choose an existing book AND a parent page within that book!?

admin/help/book doesn't help much,
http://drupal.org/handbook/modules/book/ has not been updated yet for version 6.x and
http://groups.drupal.org/drupal-dojo/book-project seems to discuss some of these changes, but fizzles out before explaining them fully...

Any help much appreciated.

t.

Comments

tanoshimi’s picture

Ok, so scanning through the book_update_6000 function in book.install has enlightened me (a bit), but it's not that easy to follow... I'll try to document what I've found, and make this into a handbook page when it's complete.

  • The addition of the need to select a book first before selecting a parent is in order to make a better UI rather than having to scroll through all book pages as potential parents when adding a new page, you can only choose pages from the book you selected. This makes sense.
  • To facilitate this, the book table now contains a bid (Book id) field - which is the nid of the top-level page within the book.
  • Each page within the book also has a mlid (Menu links id) field to join to the menu_links table. This is necessary because the hierarchy of book pages is now done in menu_links rather than in book.
  • This is where it gets a bit complicated, because I have yet to figure out the detail of the new menu_links table, but it seems that plid in menu_links gives the mlid of the parent book page, module is always 'book', and menu_name is a string with 'book-toc-' + the nid of the top-level page within the book.
  • However, there's still a lot more fields in menu_links that I haven't quite worked out what they do yet - router_path, link_path, and the mysteriously title p1, p2, p3, p4, p5, p6, p7, p8, and p9, which seem to be some sort of uber-hierarchy system.... not sure what to do with these yet

Will continue investigating...

CompShack’s picture

Just wanted to thank you for posting your findings. This is what makes Drupal a pleasant CMS to use!

-----------------------------------------
Finally, I CMS that I Like!
http://www.CompShack.com

natuk’s picture

These appear to store the previous parents of a node. I.e. not only the direct parent but the whole chain to the top-level node. If I have understood this correctly, does this mean that the maximum number of generations in a hierarchy before a node are 10? Isn't this a dreadful limitation?

BlakeLucchesi’s picture

Thanks for posting. I am currently investigating upgrade options for the book module and/or the outline module, I really like that book v6.x allows you to define any content type to be part of the book hierarchy, which is what the outline module does for drupal 5. I would imagine that as long as you can translate the hierarchies to a different table layout it shouldn't be incredibly difficult, considering at the base level it is still just a hierarchy with nodes pointing to one another.

prokopton’s picture

Does anyone know the complete mysql command to re-create the "book" table for Drupal 6.19 using the mysql command line?

Thanks.