Creating structured documents with books

Last modified: November 8, 2009 - 22:21

A book is a set of pages tied together in a hierarchical sequence, perhaps with chapters, sections, subsections, and so on. You can use books for manuals, site resource guides, Frequently Asked Questions (FAQs), or whatever you'd like.

Users who have permission can create a book and write, review, modify, or rearrange the pages. Many users can work together on a book -- you can allow or disallow collaboration, to whatever extent you want.

Creating, modifying, and administering books

On the books administration page (administer >> content >> books), users with proper permission can view a list of all published books on your site. For each book there's a link to an outline, from which you can edit or delete pages or sections, change their titles, or change their weight (thus putting them in a different order). In some versions of Drupal, you can also check for orphan pages (pages that have become disconnected from the rest of the book); in other versions of Drupal, pages cannot be orphaned.

When a user creates new content of type Book page, they can add their page at the level of their choice in a book, or start a new book if they have permission. This is called defining the "parent" for a book page, and is in the "Book outline" section of the edit screen.

You also can change the position of a page in the book hierarchy later from the page edit screen, by changing the "parent" to which it belongs. Any "child" pages of the page you are editing will automatically be moved too, so if the page you are editing is a section header, this allows you to move an entire section.

On the access control or permissions page (administer >> access control or administer >> user management >> permissions, depending on your version of Drupal) you can assign users with various roles the permission to create book pages, to create new books, and to edit their own book pages or the pages of others.

You can also give permission to outline posts in books or add content to books (depending on the version of Drupal you are using). Users with this permission can take any other type of content on your site and add it to a book. When viewing content they'll see an outline tab, and by clicking it they'll come to an interface that lets them move the content into a book.

Book navigation and menus

When a visitor to your site is viewing a book page, they will automatically see links at the bottom for navigating to the previous page and the next, and a link labeled up that leads to the level above in the structure. There will also be a link to a printer-friendly version of the page at the bottom, for users with permission to view printer-friendly versions of pages.

The Book module automatically generates a contents page for each book. However, if the books on your site are complex, you may find that you need additional navigational aids beyond the table of contents and the previous/next/up links for users to understand where they are in your book. One navigational aid you can use is the book navigation block, which you can enable on the blocks page (administer >> site building >> blocks). Enabling this block will turn on a menu that shows where the user is in your book; the menu is only visible when viewing the book.

Another navigational aid you can add to your site is a books link in any of your menus, which will take users to a list of your books. The books menu item is automatically part of the Navigation menu, and you can enable it from menus page (administer >> site building >> menus). You can also add this link to any menu you want (click "add menu item," and enter "book" in the "path" field.)

Note that the "books" link takes users to your books. The "book navigation" block helps users move around inside your books.

Quick reference

Here are the common operations with books. You can:

  • create a new book, by creating a new book page and defining it to be a top-level page in the "parent" field
  • create new book pages: create content >> book page.
  • administer individual books (choose a published book from list): administer >> content >> books.
  • set workflow and other global book settings at administer >> content >> content types >> book page.
  • enable the book navigation block: administer >> site building >> blocks.
  • control who can create, edit, and maintain book pages at administer >> access control or administer >> user management >> permissions.

create new book

markatasu - July 24, 2009 - 16:42

The instructions to create a new book are not correct under Quick Reference : you can't access the Parent field until the book exists and is selected. To create the new book, create the new Book Page with the Title for the new book, then select <create new book> in the Book Outline section, then Publish the page. Now the new Book will be listed in the Book selection field.

Print Output

aifischer - July 28, 2009 - 19:45

Is there any way to output an entire book to print? Or is it single page only?

Built right in...

spidersilk - August 14, 2009 - 07:34

In Drupal 6, at least, there's a "Printer-friendly version" link at the bottom of the content area on each book page, which will take you to a page with all the content of that page and any subpages it may have, all in one document with things like the navigation menus stripped out.

So if you click that link on the top-level page of a book, you will get the whole book in one document, ready to print.

Not sure if this applies to earlier versions, though.

Lynna

Spider Silk Design: http://www.spidersilk.net

Order of books

rex_the_first - September 28, 2009 - 17:22

Hi,

I have three books, A, B, C. With the book navigation block how do I alter the order I can change:
A
B
C

to

C
A
B

Cheers.

I wonder about the same... Is

Geir19 - October 12, 2009 - 11:55

I wonder about the same... Is it possible?!

Order of Books

jsharp - October 28, 2009 - 16:18

Two ways I know of (using 6.14 here). The easiest, go to admin/content/book and click on the "edit order and titles" link for the book you want. It will give you a drag n drop equivalent to the menu editing feature, allowing you to reorder and manage nesting. Btw, you can also get to this page from a book or book page by clicking on the Outline tab, and then the "reorder and entire book" link.

The second way is from a book page, click on the Outline tab. From there you simply adjust the weight and/or the parent. The trouble with this second approach is you don't get the holistic view of the outline, so the first approach is much more productive.

Note that to reach these pages you must have the permission: book module -> administer book outlines

Order of books is separate from order of pages within books

spidersilk - November 4, 2009 - 02:05

I think what that person was asking was how to change the order of the actual books shown in the book navigation block, not the sections within an individual book. admin/content/book doesn't let you do that, unfortunately. The only way I've ever found is to change the names of the books so that they stack differently in alphabetical order.

Lynna

Spider Silk Design: http://www.spidersilk.net

Disabling...

ChanceFound - October 1, 2009 - 21:00

Is there a way, to disable users from editing other user's books/pages?

I like that this feature automatically creates a list of the inner chapters/pages... But I think I would prefer to disable the capability for users to add pages to other's work.

Thank you!

How to customize/theme a book page?

DrakeGuan - October 25, 2009 - 16:16

I wonder how to customize or theme a book page? Is it possible to have per-book-page theming?

-- Drake

theming a book page

Mershin - November 3, 2009 - 19:21

Well a book page is just a node in essence.

If you want to theme at the page level for just that book page...

Copy page.tpl.php as page-node-nid.tpl.php

That works for any node regardless of the content type.

Also I've done page-story.tpl.php to provide a theme at the content type level, so perhaps page-book.tpl.php would work. I haven't tried it.

Can I prevent users from changing the book order

mnm_mike - November 6, 2009 - 16:48

I want them to be able to add to the book but want to force every level and child levels to be alphabetic. This would require the weight to be hidden from the book outline when they create content.

Thanks!

Printer-friendly version

svanleent - November 7, 2009 - 09:47

How do I set the stylesheet of the exported version of the book. The default version used by the book module itself is not at all enough for my users to be able to print the book (or part of the book) in any proper fashion.

Also, how does it work with theme-defined classes?

Sjoerd van Leent
Realworld Systems - Geo-IT made real

 
 

Drupal is a registered trademark of Dries Buytaert.