Add a component to export books and their pages. Ideally it would support the following usage:

  1. Export whole books - select a book and all nodes and book structure are exported.
  2. Export selected book pages. This would allow different features to contribute pages to a common book. E.g. a user manual book with pages supplied by enabled features.

It looks like this could be achieved fairly easily by adding book structure information to node exports...

Comments

chaps2’s picture

StatusFileSize
new9.22 KB

Here's a patch.

The trickiest part was dealing with the fact that nodes are exported (and therefore loaded) in an arbitrary order. This means that the book hierarchy can only be reliably created after all the book nodes have been loaded. For this I needed a new hook in uuid_node_features_rebuild() which is called after all nodes have been rebuilt.

The patch supports both usages listed above although you'll need the patch in comment #1 of #935726: Feature conflict: unnecessary nodes, node types, terms, vocabularies, and files in order to export selected book pages and avoid a conflict on node type.

chaps2’s picture

Assigned: chaps2 » Unassigned
Status: Active » Needs review
chaps2’s picture

StatusFileSize
new9.26 KB

Found a bug - this fixes it.

chaps2’s picture

StatusFileSize
new8.83 KB

One more patch... this time I've moved the new hook to it's own issue - #1049760: New hook invoked after all nodes have been rebuilt. I made another patch that invokes it so it made sense to give it it's own issue and patch.

So, to use this latest patch you must also apply the patch in comment #1 of #1049760: New hook invoked after all nodes have been rebuilt.

mlncn’s picture

Subscribe... currently i'm doing this with update hooks in a special content feature run (by script) after all the other features are set up, but i wanted to say i had this use case.

scottrigby’s picture

@chaps2 this should probably enable the book module as a dependency, in uuid_book_features_export():

+  $export['dependencies']['book'] = 'book';
   $export['dependencies']['uuid_features'] = 'uuid_features';
vectoroc’s picture

Status: Needs review » Needs work

perhaps you know that the book module contains next code

    case 'presave':
      // Always save a revision for non-administrators.
      if (!empty($node->book['bid']) && !user_access('administer nodes')) {
        $node->revision = 1;
      }

it produces many php warnings like query: INSERT INTO uuid_node_revisions (vid, uuid) VALUES (44, 'cd9cd0cc-cf19-11e0-a511-fefd6d4ac813') in ...

I see 2 workarounds:

  • to override $node->revision flag in uuid_features_nodeapi presave
  • to call book_nodeapi directly (I know it's a hack) on rebuild stage it will call book's hook_nodeapi and book will override revision property

Actually this patch does not recreate all book structure (probably something wrong with sorting)

vectoroc’s picture

node_get_by_uuid does not work in some cases
I've replaced it with node_load(uuid_get_serial_id('node', 'nid', $uuid)); and now it works

vectoroc’s picture

vectoroc’s picture

Also I've found that it's important to set $node->book['module'] = 'book';
Otherwise book menu link wont work correct

scottrigby’s picture

@vectoroc do you want to re-roll a patch for this issue, to go along with #1261196-5: node_get_by_uuid should not pass query through db_rewrite_sql?

Also, are you using one of the patches from #1049760: New hook invoked after all nodes have been rebuilt?

vectoroc’s picture

May be later.
I use #1049760: New hook invoked after all nodes have been rebuilt #1 patch

There is my patched version of uuid modules

oleksa’s picture

Is there an equivalent for D7? I am looking into using a Drupal book content type to maintain software help docs for an open source project, so drupal could be leveraged to enable the collaborative work on those docs, which then could be exported to static html to be loaded into the help browser in the software.

  • das-peter committed 3927c83 on 7.x-1.x authored by chaps2
    Issue #1048470 by chaps2, mlncn, scottrigby, vectoroc, oleksa, das-peter...
das-peter’s picture

Version: 6.x-1.x-dev » 7.x-1.x-dev
Issue summary: View changes
Status: Needs work » Fixed
Related issues: +#1049760: New hook invoked after all nodes have been rebuilt

Woohoo, I've just re-rolled and adjusted the patch to work with the 7.x-1.x version.
Tests were successful and thus it's committed :)
Thank you all for working on this.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.