Currrently, in the book module, clicking 'next' gives you the 'next sibling' as opposed to the next page in the book ('first child' or 'next sibling' if there are no children).
Example: clicking 'next' from the introduction page of the Drupal Handbook leads you to the Administrator's Guide, which is the next node on the same level, and not to the first child (About this handbook) as one would think.

I don't know if this is intended behaviour, but it is not what I would expect. It certainly makes it impossible to 'page' through the book in a linear way, which seems a more obvious thing to want do than paging through the high level nodes only.

Comments

Anonymous’s picture

Assigned: Unassigned » Kjartan

I agree that this isn't logical. It is the intended behaviour as some online manuals do it this way. But I will change it unless someone can explain why this way is better.

Anonymous’s picture

I'm struggeling a little with making this work without adding a really complex system. Contemplating making a support table that maintains the order of nodes so each book page view doesn't result in 3-6 queries to find the next/prev links. Any suggestions, thoughts?

moshe weitzman’s picture

This isn't really an answer to your problem, but i suggest looking at the taxonomy functions for ideas on efficiently traversing a hierarchy. the term_node table is completely analogous to the book table.

Dries’s picture

Component: Code » book.module

See Ax' sandbox for a patch that fixes this problem.

al’s picture

Assigned: Kjartan » ax

I'm reassigning this to ax, seeing as he's the one who's patched this.

Although ax's fix has been committed to CVS, it doesn't get things quite right...

The book module treats nodes that are first-level children of <root> as a special case - they are the top level nodes of different books. Anything beneath this level belongs to one of these books.

Ax's patch gives prev/next links *between* books, which shouldn't happen. I.e. the last page of book one links to the first page of book two and vice-versa. The book_prev and book_next functions need to check to make sure they're not looking into a different book.

ax’s picture

Title: next page in book » [PATCH] Re: [drupal-devel] bug #165 : next page in book

> 2003-03-10 22:33 : Al Maw
> I'm reassigning this to ax, seeing as he's the one who's patched this.
>
> Although ax's fix has been committed to CVS, it doesn't get things
> quite right...
>
> The book module treats nodes that are first-level children of
> as a special case - they are the top level nodes of
> different books. Anything beneath this level belongs to one of these
> books.
>
> Ax's patch gives prev/next links *between* books, which shouldn't
> happen. I.e. the last page of book one links to the first page of book
> two and vice-versa. The book_prev and book_next functions need to
> check to make sure they're not looking into a different book.

attached patch fixes this. it also fixes

- the index link ("View this book's table of contents.") which pointed
to http://drupal/book instead of to ... this book's table of contents.
- it doesn't print "previous", "next", "up", "index" if there are no
"previous", "next", "up", "index"
- it doesn't print "index" if "up" /is/ the "index"
- it swaps the order of "up" and "index", ie. "up" is in the row above
"index", between "previous" and "next" now. this is more logical and the
way all tree-browsing apps (python doc, info, ...) do it.

please check and apply.

al’s picture

Priority: Major » Normal

Confirmed behaviour and tested quite extensively.
Marking this *fixed*.
Please commit to CVS.