Duplicating the Book Module
(I posted this in the wrong section yesterday so have copied it to here. I can't delete it from the 'post-installation' top level).
I have been plugging away at duplicating the Book module and have been surprised with the progress (I am not a coder).
The current conundrum has to do with the 'Outline' functionality. I'll explain what I have done so far and then describe the issue that I am hoping a coder out there can shine some light on for me.
this is all gleaned from the How to make a duplicate Book module for version 4.7. And with some clarity help from VeryMisunderstood at node/185709
- Take site offline and backup database (/admin/settings/site-maintenance)
- Disable the book module (/admin/build/modules)
- Copy the \drupal\modules\book directory to \drupal\sites\all\modules\book (or to \drupal\sites\modules\book if you are not working with a multi-site set up)
- Edit the \drupal\sites\all\modules\book\book.module file
- Find:
if ($type == 'node' && isset($node->parent)) { - Replace with:
if ($type == 'node' && isset($node->parent) && $node->type == 'book') { - Delete line 2, it looks like this:
// $Id: book.module,v 1.406.2.1 2007/02/14 04:30:33 drumm Exp $
- Find:
- Save the file and you can now re-enable the book module (/admin/settings/site-maintenance)
- Now make a copy of \drupal\sites\all\modules\book in the same directory and give it a new name, I am calling it wikibook
- Go to \drupal\sites\all\modules\wikibook and rename every file:
- book.css to wikibook.css, book.info to wikibook.info, book.install to wikibook.install, and book.module to wikibook.install
- Open each file and rename each instance of 'book' with 'wikibook', each instance of 'Book' with 'wikiBook', each instance of 'book_' with 'wikibook_', each instance of 'book navigation' with 'wikibook navigation', etc. I counted a total of 269 edits on the book.module.
- Save all files
- Enable wikiBook
This should leave you with both a working Book and wikiBook content type. Next step for me was to go to configure the wikiBook content type to create revisions and then enable all users to have access to create wikiBook pages, to edit wikiBook pages, etc, and to ensure that on the Book content type that only certain roles be able to edit all book pages and everyone else can only 'edit own' book pages.
The problem I am now grappling with is that on both Book and wikiBook pages, if I select the 'outline' tab, the first two lines on the page are:
The outline feature allows you to include posts in the book hierarchy.
The outline feature allows you to include posts in the wikibook hierarchy.
there should be one or the other. Also, the 'parent' hierarchy dropdown defaults to the new wikiBook hierarchy for both the wikibook and book, regardless of whether it is a book you are actually using.
(Note: I also have the BookExpand module to use with Organic Groups, so basically did the same thing with it. I have the Book Expand module to filter the book hierarchy so that when a member of a group selects to create a book page they would be limited to creating books within their group. Also, when a new group is created, the Book Expand module automatically creates a new book for that group, and now the wikiBookExpand module does the same function for groups, creating a wikiBook as well as a default 'handbook'.)
Hopefully someone can help me reconcile this, otherwise its back to the drawing board, disabling Organic Groups and going back to using the Taxonomy Access Control with lots of roles to manage.
Thanks

Book Expand
I'm not really sure how that would work. I created the Book Expand module, and obviously never intended for its use with a different content type. My guess is that the way that the Book Expand module changes the form needs to be adjusted.
If you look in the wikiBookExpand module, you'll find a function, probably called 'wikibookexpand_form_alter'.
It basically checks for the existence of $node->parent, what you want to do is check to see if $node->type == 'wikiBook'.
Does this make sense?
Dave
My site: http://www.unitorganizer.com/myblog
Thanks for the suggestion
I made the changes, and still ran into the same problem, but while reading the code in the book module, it dawned on me that the 'outline' tab should not even be showing up on a book page, or my wikibook content type for that matter, since both content types already have the outline feature built right in the 'parent' dropdown list (which is working). So what I really need to figure out, is how to edit the outline functions in the book.module file to not display on book or wikibook content types, and to display properly on all other content types... Well, actually, the wikibook outline feature is not even necessary, so to simply remove that function from the wikibook all together would be fine. For now I am simply going to not allow for any one to have the ability to use the 'outline' feature and hopefully can sort it out over time and re-enable it.
How about the drop-down parent list?
Did the change I suggest make any difference to the drop-down parent list?
Dave
My site: http://www.unitorganizer.com/myblog
Unfortunately not,
the drop down works in the edit tab, but not the outline tab. In outline, it defaults to just one, the new wikibook outline.
I just discovered another bug though, when I log in as a user other than one with full admin rights I have a link to the create wikibook content. But when I log in with a non-admin account that does have full rights to the wikibook, the create wikibook content link does not show up.
To bad, seems there are many many more coding tweaks that would need to be done to make this work. This functionality is far more complex than my simple 'find and replace' capabilities can account for... If it wasn't, I suppose it would already exist, since, it seems to me, if Drupal is used as an intranet, that both granting and limiting access to various instances of the same content type would be a highly regarded feature (along with OG level access control).
All that said, I will try again with a fresh copy of the book module when time permits... I could very well have missed or mucked up an edit or two... For now, I think we will have to move on to a different solution.
Thanks
some improvements
started again and figured out that after enabling the new 'wikibook' module and 'wikibook expansion' module, that I get this error when navigation to the 'create content' and selecting wikibook
user warning: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '% ORDER BY b.weight, n.title' at line 1 query: SELECT n.nid, n.title, b.parent, b.weight FROM node n INNER JOIN wikibook b ON n.vid = b.vid WHERE n.status = 1 AND n.nid <> % ORDER BY b.weight, n.title in C:\www\drupal\includes\database.mysql.inc on line 172.Also, the parent drop down only contained 'top-level' and nothing eles.
I found that if I configured the admin/settings/wikbookexpand settings to filter for type 'group' and then click the 'go' link to create the wikibooks, and then return the setting to filter for 'none' that error went away and parents drop down was correctly filled.
Same with the admin/settings/bookexpand settings.
I tried the filter setting without any of my changes on a different test site, and found that the admin/settings/bookexpand 'group' filter did not seem to work there either. The parent drop down only had the one selection 'top-level', no matter which book your were editing, adding a page to, or which group a user belonged to. If you were adding a sub page in an existing book, that page was created at the top level as a new book. So this may be a pre existing issue with the book expansion module, or I am not configuring it or understanding it correctly.
Any ideas?
At least I think I can use the wikibook now which really solves a big problem with having book like content that various groups can edit, read, or be restricted from.
Thanks
Book Expand
The Book Expand module requires a top level Handbook book page has been created for each group before you can use it properly. It includes a script to create these book pages if you enabling it on a new site (which I have used very successfully myself, see http://www.openplanner.org ). If you don't have these Handbook pages, it will produce unexpected results.
Dave
My site: http://www.unitorganizer.com/myblog