For many types of documents which are categorized into books, it would be useful to have automatic numbering of pages, which would be updated as the book changes.

For example, suppose I have the book

Proposal
- Overview
- - Current status
- - Proposed updates
- Implementation
- - changes to core modules
- - new modules

It would be useful to have it automatically assign numbers such as

Proposal
- 1. Overview
- - 1.1 Current Status
- - 1.2 Proposed Updates
- 2. Implementation
- - 2.1 changes to core modules
- - 2.2 new modules

so that if I were to insert a new page between 1.1 and 1.2, it would change to look like this

- 1. Overview
- - 1.1 Current Status
- - 1.2 Issues to address
- - 1.3 Proposed updates

Eventually, it might be useful to have different styles of numbering at different levels, but for right now, just being able to have a book automatically numbered would be useful.

I will look at working up a patch for this to the book.module included in 4.6.3, but I'm only just learning how to work with Drupal, and probably the 4.7 version (when it comes out) will break the patch.

If anyone has an idea of how this could be implemented as a module completely separate from the book module, I'd be interested in hearing it. I don't think it's possible without having the number become a part of the title when the page is edited, which would be suboptimal.

Comments

puregin’s picture

This seems like useful functionality.

Doing this will require traversing the entire book, so you probably don't want to do this for
every page view.

The ideal thing would be to associate the generated numbering with the combination of (node, book) in the book table the first time this is computed, and then to update this when the book structure gets updated.

The ouput should probably be generated in a themable way, so that roman vs. arabic numbers vs. no numbering can be tweaked in the stylesheet (I think this can be done in CSS, no?)
The numbering should definitely be generated an prepended to the title in book_view() rather than being stored with the title! Of course one should probably do the same thing when displaying the subsections and next/previous/up links.

Djun

pukku’s picture

Further thought on this suggests that I probably really want a new data type, which I would base on the book.module. In addition to the ability to display numbers, I really want to be able to order things more particularly than with using weights.

Currently, I think that the best way to do this will be to instead of a weight, have a link the the "previous" node; that is, at each level of the structure have a linked list of the pages.

Since I suspect that the ability to have sectional numbers is very commonly tied to the ability to carefully order pages (not that weights don't allow ordering, but they only really allow up to 30 items at a level, and they aren't particularly intuitive to the people who I will need to be using this), I'm starting to think that a separate module is the better solution.

fedupguy’s picture

This would be a great feature. I have been looking for a solution to enable the collaborative production of long technical policy documents ultimately intended for print within UK Local government.

To this end automatic generation of harvard style paragraph numbering is essential.

Also useful would be automatic numbering schemes for footnotes, endnotes, figure captions etc. A final desirable would be to be able to use a sequnece of arbitrary numering for specific types of tagged content.

for example it could be used to enter data conforming to this schema: http://www.govtalk.gov.uk/documents/schema_doc_developmentplansv07.zip The development plans v7.xsd

So that the document structure might run

1. Housing

1.1 ...

1.2...

H1 Policy Title

Policy Text

1.3...

Etc.

With the H1, H2, H3 or other arbitary numbering systems all being the text tagged with the
tag from the schema

pukku’s picture

At my job, we've developed a module which does the automatic numbering. It won't do letters or anything like that though — we may eventually get around to doing this. Hopefully we'll make it generally available, but we still need to thoroughly test it and clean it up a bit.

puregin’s picture

Version: 4.6.3 » x.y.z

Marking this against version CVS since this is a feature request.

I suggest that this is something that might be approached by having some kind of template expansion mechanism. This would deal with a number of other kinds of requests for embellishing or 'decorating' output from books.

LAsan’s picture

Version: x.y.z » 7.x-dev

Still a feature request?

pgi’s picture

Definitely yes

pukku’s picture

Yes — it would still be very useful...

andreasreiser’s picture

I would really be very glad, if this functionality could be implemented! Subscribe.

macko’s picture

I implemented such functionality some time ago (for own cms, not for drupal) just using <ol>, <li>, and properly placing the h1, h2, h3, ... tags on individual pages. This was simple and worked well, but this solution is a "display-only" numbering (i.e., rendered by the browser). This also required careful usage of the heading tags (h1,h2,...) but was efficient and worked well. It also allowed to have subsections within individual pages, which nicely integrated into the general outline.

sun.core’s picture

Version: 7.x-dev » 8.x-dev
glennnz’s picture

Did anybody get anywhere with this?

TomiMikola’s picture

I just created a module for this functionality. Works quite well. Check out at http://drupal.org/project/bookchapters. (Currently only for D6)

glennnz’s picture

Tomi, you're a legend!!

A couple of questions, I won't get a chance to try this for a few days yet:

1. Does the node title get changed? I don't think so from your description.
2. Any plan to include the numbering of paragraphs within a node?

Cheers

Glenn

ecoluke’s picture

Version: 8.x-dev » 7.x-dev

The book chapters module doesn't work so well - it doesn't assign numbers to the previous, next or children links in the book navigation section.

Is this still a consideration as a feature request because it would be very useful?

shap’s picture

In re the very first comment by puregin, where he said:

Doing this will require traversing the entire book, so you probably don't want to do this for
every page view.

This is incorrect.

Naive requires an upward-recursive traversal of a node's parents. Each node needs to know it's position in sequence relative to the other nodes that are children of the same parent. That is: the worst-case cost is log(height). But in reality it's simpler than this. Whenever a child node's ordering relative to its parent node is changed, we need to update that child and all of its successors to record their new position. The number becomes a persistent attribute of the child node.