Closed (fixed)
Project:
Drupal core
Version:
6.x-dev
Component:
book.module
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
29 Aug 2006 at 01:19 UTC
Updated:
10 Aug 2007 at 21:54 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
pwolanin commentedprogress in this patch:
Comment #2
pwolanin commentedthe code's not fully baked, but selecting a default child type for each book is starting to work, and the admin page for seleting book types is halfway there.
Comment #3
pwolanin commentedchnged all instances of code of check for 'book' type to checking against the types set in the admin interface.
Comment #4
pwolanin commentedAfter thinking more about this I think that that the approach of forcing all nodes of a given type to be in the "book" class is not the way to go. The code is already pretty well set to allow individual nodes of any type to be added to the "book" class, and I don't see any real advantage to the per-type approach.
So, here's what's next then: eliminate the book node type. Change the code to check in other ways for membership in the "book" class (e.g. nid == book_id). figure out a UI/workflow for adding/removing nodes into/from the "book" class. This last I'm unsure about and would apprecaite suggestions.
the only downside I can think of to this is that in book_nodeapi($op='load'), it becomes necessary to run two simple queries (or a LEFT JOIN?) instead of one query for every node since there is no way a priori to know (based on the type) that the node is in the "book" class.
Another question- should nodes of the book_page type be requred to be in the book hierarchy?
Note that this is somewhat full circle back towards the existing book module, but will provide a better UI (in terms of moving nodes within a book), the flexibility to desognate an alternate node type as the default child page, and a TOC for each book. In addition, this positions the module to be used by a contrib access control module to set permissions on a per-book basis.
Comment #5
metzlerd commentedI'm sorry for jumping in late, here but you did ask for conceptual feedback :).
Regarding the "book Cover".
I agree with Dries when he that creating a "book" node type that means something special to the hierarchy might not be a good idea. If you consider that books may get _very_ large, each of these problems might crop up again. A section of a book that has too big of a hierarchy may get unwieldly? What if I want to add a table of contents to each section of a book? Wouldn't it be cool if the the problems features could be solved at _every_ level in the hierarchy.
Here's an alternative way to think about the problem, ideally each of these would be separate patches:
1. Make the books module node independent. Implement the changes you've started to configure which content types are candidates for becoming a book page. UI becomes consistent by using alter_form hook to place the controls in the same way on all book page candidates. Theoretically, then the book page module could just be another node type instance of the "page" module.
2. Implement a "levels feature" in the TOC. Every page in a book already includes a TOC. The difference is that you want one that goes deeper into the hierarchy. Add a setting to each node to for the book maintainer to control the depth of the hierarchy reported below the node content of the book.
3. Implement the "only show pages belonging to this book" as on option in "books settings" until 4 is dealt with appropriately.
4. Ultimately, solve the unwieldy navigation problem with a proposed patch to the forms api. The ideal solution would be an AJAX based solution that fails back gracefully to the existing navigation choice. The unwieldy tree navigation problem really needs solving. It's a problem for the menu interface every bit as much as the book interface. Currently this has been worked around in the menu module, by changing the "menu settings" to limit choices to a specific "menu", and I'm rapidly running up against the limitations of that. There are tons of modules that would benefit from a well designed solution, here (e.g. taxonomy, books, menus).
Comment #6
magico commentedAlso this feature Define a book as protected and new 'edit protected books' permission would be nice to take a look and perhaps take in account within this strategy to "separate books"
Comment #7
Anonymous (not verified) commentedI don't have the expertise needed for commenting on the conceptual issues concerning code.
A non-expert's comment:
The end user needs to see navigation that is clear. And for this it must be neat and orderly.
So effective theming would be needed to clean up the symbol-heavy table of contents seen at http://book.wolanin.net/node-6-book.
When what the end user sees is tidy, neat, and clear, he'll most benefit from the valuable improvements you're making.
Best wishes.
Comment #8
pwolanin commentedOk, this is wroking reasonably well now, but needs some additional cleanup and thought about the settings page (perhaps to set default TOC depth, & default child page type for nodes moved into the "book" class).
with this patch, we're back to a single node type being defined, book_page. book_page nodes are just like page nodes - they are only added to the book hierarchy via the "outline" tab or through a link to add a child page. They also serve as the defualt child page type.
A node that's in the book hierarchy can be "promoted" to be a "book" via a checkbox on the node edit form (I'm not sure if this is the best UI- comments welcome).
A node that is a book can be demoted similarly via a checkbox in the edit form and go back to being a regular page in the book hierarchy.
@magico - certainly intersting, but at this late stage I think any added access control needs to be though an add-on module
@OGovinda - the symbols there are just the default Drupal menu symbols. these can be changed in the CSS.
Comment #9
pwolanin commentedadded administrative settings to choose the default TOC depth and child type. The book_page type goes automatically to book_id == 0 (getting back to be more similar to 4.7 book.module), but can be immediately promoted to be a book via the check box on the form.
Also spent a while updating to conform to this patch: http://drupal.org/node/68418, and got hung up on this recent (inexplicable) change to node.module:
Please review.
Comment #10
pwolanin commentedpatch #9 doesn't apply becuase I had diff with the wrong CVS tag. Attached patch should apply cleanly to book.module v. 1.387
Comment #11
pwolanin commentedimproved permission checking - prevents users from using the query string to add posts to a book unless the type matches the child type set for that book.
Comment #12
pwolanin commentedFor testing purposes, attached script uses the new form method for node submission to create book pages that are associated with the pre-existing books. Make a few books before running this.
Comment #13
pwolanin commentedattached patch fixes 2 minor bugs -
1) the "Make this node into a book." checkbox was showing up on the outline page, where it had no effect.
2) ran in the opposite problem with the node type in the node/add/type URL and had to convert back with
$type = str_replace('-', '_', arg(2));Also restores the 4.7 behavior that users without "create new books" permission cannot create a top-level "independent" book page.
Comment #14
pwolanin commenteduse this one instead of #13
Comment #15
pwolanin commentedupdated for HEAD. Moved functionality back into book_nodeapi (per http://drupal.org/node/68418), cleaned up code and comments, and fixed minor bugs in functions select_book_page_parent, and book_page_menu_tree.
Comment #16
pwolanin commentedFor testing purposes, there is a script: http://drupal.org/node/65319#comment-127289 for creating nodes before applying the patch to test the update function.
Attached is a script updated for latest patch/HEAD for creating book_page nodes, including some put into the "book" class.
Comment #17
pwolanin commentedtest site updated with patch#15 and new sample content: http://book.wolanin.net/
Comment #18
beginner commentedI cannot connect to http://book.wolanin.net/.
I'll review the patch soon (probably today) anyway.
Comment #19
pwolanin commentedthe test site seems accessible now- that host is not 100% reliable (I'll be switching as soon as the contract is up next month).
Comment #20
pwolanin commentedFYI, for those reviewing the code and thinking about how this enables new possibilities. In a subtle way, per-book permissioning is already available in this patch. Here's how: with the new create-content-types functionality in core, you can create multiple simple content types. If you set a particular type as the default child page type for a single "book", then only users with the permissions to add/edit nodes of that type will be able to add/edit pages in that book.
Comment #21
kpatrickdj commentedI followed the long thread of posts and many patches on this topic. However when I tried to apply the patch flexbook_15.diff, I found this diff expecting Drupal 5.0 installation.
If there are not many 5.0 features mandatory for this to work, can you please create and upload a patch for 4.7.x versions for testing on 4.7 installations.
Thanks.
Comment #22
pwolanin commented@kpatrickdj - this was a proposed feature for the current development cycle. This patch was not accepted, and as you noticed no longer applies to the current HEAD.
In a few weeks, I may try to resurrect this work into a replacement for the book module for 5.x. Feel free to try to update the patch if you wish.
Comment #23
pwolanin commentedmaybe for 6.x. thinking about a comment on the previous thread along the line of "why not show a full TOC for every page", a better way forward might be to just add 3 new columns to the book table- book_id, child_type, and toc_depth. Obviously, for non-admins the values for a child page would just be inherited from the parent, but this would provide great flexibilty in structuring a book.
Comment #24
pwolanin commentedhttp://drupal.org/node/146425