Wondering if anyone has worked out how to have book pages sorted by date entered (which would also be by node#), instead of alphabetically after weight.

I have set up a book to post meeting minutes, which I thought would be perfect for this, and is, except for the sort order (on the parents page, the book navigation block, and the print version).

Adjusting the weight each entry is not a good option.

I can find where it's sorting in the code, but it's very integrated throughout, calling the weight + title. I don't know how I can target the node# or date.

I can read + edit php, but not savvy enough to rewrite this complex module.

Comments

DriesK’s picture

The sorting happens in the database queries. If my grepping is correct, there are 11 places in book.module where you should change the query, if you want them all changed. Search in book.module for 'ORDER BY'. You'll find stuff like:

ORDER BY b.weight DESC, n.title DESC

or

ORDER BY b.weight, n.title

This means, as you already indicated: first order by weight, then by title. If you only want to order by creation date, you'll have to replace all of these by

ORDER BY n.created

You can add ASC or DESC after that, to have the results in ascending or descending order.

You can also use n.changed: this is the date on which the node was last edited.

If you want to order by node id, you should use n.nid.

echoz’s picture

Thanks so much, this is great!

The previous + next is still working by date.
I spent a lot of time editing but could not have it recognize previous + next by date created or by id. Another nudge would be greatly appreciated.

-----------------------
http://echozone.com

N1L’s picture

Can anyone update this code so it can work with book.module for D6?