Book Module - Adding page number navigation

silurius - July 3, 2008 - 23:39

For a new 6.2 site, I'm customizing the Book module by maintaining a separate copy of book-navigation.tpl.php in my theme directory. I started by removing the tree and converting the next/previous links into buttons. Because my content can get as big as twenty pages (but more often between 6-12), I would like to include page number navigation as well.

Needless to say, I could create these manually within the nodes, if I really had to. And there are at least a few other module-based solutions for this, but none that would integrate well with my current Views/CCK/Book setup (so far as I can tell).

What I would really like to devise is a way to add a query to book-navigation.tpl.php that grabs the total number of pages at a given book depth and present numerical links to each of those pages.

I note that this has come up before (example), but I'm not sure if anyone has actually addressed it here yet.

Add a serial int auto-incrementing db field for the node type?

remedios - October 26, 2008 - 02:30

I think that this question could be answered with a "serial" type auto-incrementing database field in the node (page) members of a book. Add a field to the node type you're working with, and set the field type to "int serial" to increment each time you add a page to a book. To display the number, pluck that item out of the database with a db_query() or db_fetch_object() and display it.

I'm interested in a more elegant solution. The serial data type idea has a problem, which is that if you change the order of the pages in the book, I'm not sure the page number will be correctly updated. This could also be corrected in fairly complex php code.

 
 

Drupal is a registered trademark of Dries Buytaert.