Ordering book pages

ph4nt0m - March 10, 2004 - 17:28

Hi All
I understand that you can order book pages by using the weight funtionality. However this doesn't seem a very scalable feature - I want to add a book which has more pages than would be offered by the 20 currently (weighted from -10 through to 10). I realise that book pages which have the same weighting will appear in alphabetical order - however what if I want an order other than alphabetical?

e.g. I have two book pages one called 'B, this is page B' and one called 'A, this is page A'. Let's say I want these two pages to appear at the end of my book, and I have exhausted all the previous 19 weighting options (-10 through to 9) for previous book pages. So I am left with 10 - and I want the page titled 'B, this is page B' to appear before the page titled 'A, this is page A' - however I cannot see a way to do that, if they are both weighted the same (10) they are ordered alphabetically. I have tried publishing page B first, however as soon as page A is published it moves above page B.

Is there a way to explicitly specify the ordering of these book pages?

form_weight()

moshe weitzman - March 10, 2004 - 18:06

change your form_weight function (see includes/common.inc) to include more values.

Hi Thanks for the prompt res

ph4nt0m - March 10, 2004 - 18:57

Hi
Thanks for the prompt response - I have located the function, however I am unsure what I need to change. If I want there to be say 100 weight options, what would I need to change?

Thanks.

Fourth paramater

Dries - March 10, 2004 - 19:50

Increase the fourth parameter of form_weight() whose current value is 15.

No effect

ph4nt0m - March 10, 2004 - 20:56

Hi Dries
My current form_weight function looks like this:

function form_weight($title = NULL, $name = "weight", $value = 0, $delta = 10, $description = 0, $ext
ra = 0) {
for ($n = (-1 * $delta); $n <= $delta; $n++) {
$weights[$n] = $n;
}

The fourth parameter is 10, not 15 - and if increase this parameter and save the file it has no effect on the 'weight' pull-down menu at the bottom of the book page creation form.

I concur, and bump this

Taran - December 15, 2005 - 21:12

I have increased $delta =10 to $delta=100; no effect seen in the book weights.

KnowProSE.com
eAsylum.net

I should add that I have atte

ph4nt0m - March 10, 2004 - 21:08

I should add that I have attempted to change the $delta variable, however it does not have any affect, either on the weight pull down menu for nodes, or book pages. Oddly book pages are able to weighed from -15 to 15 whereas nodes only from -10 to 10. Is this setting being set somewhere else?

I am using the polder theme, if that helps.

Solution for Book

Taran - December 15, 2005 - 21:58

OK, here's the deal. The book module doesn't use the standard weight module of the node that everyone sends people to *incorrectly* in the context of the book module.

The answer is in /modules/book.mod, in book_form():

/**
* Implementation of hook_form().
*/
function book_form(&$node) {
  global $user;

  $op = $_POST['op'];

  $output = form_select(t('Parent'), 'parent', ($node->parent ? $node->parent : arg(4)), book_toc($node->nid), t('The parent that this page belongs in. Note that pages whose parent is &lt;top-level&gt; are regarded as independent, top-level books.'));

  if (function_exists('taxonomy_node_form')) {
    $output .= implode('', taxonomy_node_form('book', $node));
  }

  $output .= form_textarea(t('Body'), 'body', $node->body, 60, 20, '', NULL, TRUE);
  $output .= filter_form('format', $node->format);
  $output .= form_textarea(t('Log message'), 'log', $node->log, 60, 5, t('An explanation of the additions or updates being made to help other authors understand your motivations.'));

  if (user_access('administer nodes')) {
    $output .= form_weight(t('Weight'), 'weight', $node->weight, 15, t('Pages at a given level are ordered first by weight and then by title.'));
  }
  else {
    // If a regular user updates a book page, we create a new revision
    // authored by that user:
    $output .= form_hidden('revision', 1);
  }

  return $output;
}

if (user_access('administer nodes')) {
$output .= form_weight(t('Weight'), 'weight', $node->weight, 15, t('Pages at a given level are ordered first by weight and then by title.'));

Where you see the 15, change to the appropriate number you wish. In fact, you will have to go through the file, find every '15', make sure that to the left of the number the association is with 'weight', and change it to the new number you want.

This should *not* be this hard. A book of more than 30 pages and one cover page should be expected...

KnowProSE.com
OpenDepth

I've written a more complete answer

Taran - December 15, 2005 - 22:27

Is this still true?

piggybank - January 15, 2007 - 18:36

We're putting up a new Drupal site (www.ultimatecrmguide.com) and are running into the limitation of the number of pages we can have (the +/- 15 = 30 pages in any one level). Is the solution *still* to hack that book file? If so, I'm assuming that this will have to be managed when doing upgrades in the future? (We're running 5.0).

thanks,

Scott Gingrich

Non-hacking answer/suggestion/bad option?

deanypop - January 19, 2007 - 19:49

I think the "drupal way" to think about this issue is that your book shouldn't have such a flat hierarchy.

Not saying that's right... Or the only way to do it, but just how the devs were thinking about it. Check out the Drupal handbook for an example of this.

I tend to find that my books, which are hundreds of individual pages at last count, can continually be broken down into chapters, sections, etc... Basically, add child pages for each section, chapter, and maybe 'atomic topic'... It's definitely not built for novels, but just about any reference type information should be able to be split up in a way that wouldn't require more than the offered page weighting (at least, if it did, I'd probably just make additional volumes/books).

My issue is with the handling of the child pages in the printer-friendly view - All the titles are the same size, there's no built-in/automated page numbering or indentation. If someone knows a way I can get that, please let me know!

-deano

A Suggestion

Ken Watts - June 5, 2008 - 16:43

I don't know if this has been addressed in 6.x, but I question the wisdom of a set range at all. Why not just a box where the user can enter an integer? It would be simpler to use, and probably simpler code. The higher the integer the later the page.

In fact, it could go one step further. It could be set up this way: "Enter the number of the page. If you entered "1" the page would become the first. If you entered the last current page, or a higher number it would become the last. If you entered "5", and there already was a 5, it would become the new 5, and subsequent pages would be renumbered accordingly...

This would also make it possible to provide normal page numbering for those who wanted it.

(I edited this on 6/5/2008 to make it even simpler.)

- Ken
www.dailymull.com

 
 

Drupal is a registered trademark of Dries Buytaert.