I'm working on a site that's basically an online book, so it seemed reasonable to use the book module, or so I thought. It seemed like the best way to manage a large, hierarchically structured body of text. But I've run into some problems that might well be complete deal-breakers unless I can find a solution.
Problem the first: the main page shows an automatically generated table of contents, which is nice, and is one of the reasons I chose this module. But... It only shows the top level chapter. I need it to show a complete table of contents, showing the full hierarchy with all levels included.
Problem the second (somewhat related): I had thought, perhaps naively, that any page that had children in the hierarchy would also show some kind of table of contents listing them, so that going to the main page of any given chapter would show links to the sections within that chapter, just like the main page does. But no. The child pages are pretty much invisible, except in the little menu in the sidebar and the previous/next links. This has the particularly bad effect of making most of the main chapter pages blank, or at most showing one or two lines of intro text and nothing else, since most of the content within each chapter is divided into sections.
These problems would seem to severely limit the usefulness of the module, and while I've searched through the contributed modules listing and the forums, I haven't found anything that looks like a workable solution yet.
There's a module called "sliced navigation" that looks like it could be used to generate individual chapter menus, but it's only available for Drupal 5, and even if it was available for D6, having to create each chapter's table of contents individually as blocks and then assign each block to the content area of the appropriate page seems like kind of a kludgy workaround.
Ideally I'd just like each chapter page to behave like the main page - showing first any content entered for that specific page, and then a little table of contents showing its children/subsections. There's got to be a way... And a way of showing the main table of contents thoroughly expanded. The client I'm doing this site for really, really wants it to be as user-friendly as possible, and that means making it very easy for visitors to find the specific information they're looking for.
To make matters worse, I'm working on a very, very tight timeline here, and need to get this done ASAP. Right now the only way I can see to do it is to create all the tables of contents manually as HTML, which kind of defeats the whole point of using the book module, and will make future updates a major pain.
Any help would be VERY much appreciated! Thank you!
Comments
Aha - I think I may have found the answer, or part of it anyw...
Specifically, the answer to the chapter contents part:
Over in the Snippets section of the "Beyond the Basics" handbook I found this: How to make a book navigation block appear on all pages.
And voila, chapter 1 now has its own contents menu. Others soon.
It still does feel like a bit of a kludgy workaround, for the reasons I mentioned in my comments on the sliced navigation module, but at least it works in Drupal 6.
Also, it won't really solve the problem of wanting a fully hierarchical menu on the main page, because while I could create a block showing the whole book menu expanded using this snippet, the main page would still be showing the regular list of chapters, so there would be two separate contents listings! For a short-term solution, I might just set the other contents menu to display:none in the theme's CSS file, but that's obviously not a great solution.
Ultimately, it would be great if someone could do a module that added more navigation options to the book module so that creating 14 separate PHP-snippet blocks wasn't necessary, or better yet if the next version of the book module itself had more configuration options. It really does seem like a great module apart from the navigation restrictions, and it would be great to see those limits removed. My PHP skills aren't currently up the task of writing Drupal modules, but maybe someday...
One more way in which this is a non-ideal solution...
Assigning the chapter contents block to content-bottom puts it not only beneath the content as I'd wanted, but also beneath the previous/next/up navigation, which looks silly and is likely to be confusing.
So I figured I'd add whatever bit of text the main chapter page contained to the block and assign it to content-top - but that puts it above the headline, which is even worse!
I'm going to try moving the regions around in the page.tpl.php file, but honestly this is all a huge headache and really underscores the need for a better solution.
Outline module allows you to select toc depth for children
The outline module does this by taking over the book module links and allows you to customise the depth of it, but the module is in alpha and abandoned, I am trying to persuade another maintainer to take it on :-)
did u find another solution?
Well, part of the problem I
Well, part of the problem I was running into (lack of chapter menus) turned out to have been some sort of bizarre random glitch, that happened only on some chapters, while others had automatically generated menus without my having to add any PHP snippets. So after a while I found that the best way to deal with the ones that didn't acquire a chapter menu was just to create a new page with the exact same content as the original top-level page of the chapter in question, move the subsections under that one instead, and delete the original. This usually resulted in a working table of contents, though I still have no idea why the glitch was happening to start with.
But I never did find a solution to wanting a full table of contents showing all subsections. I had to just explain to the client I did the site for that that wasn't going to be possible at this time because the Book module didn't work that way. I hate having to say things like that, because I normally like to think that anything's possible if you work at it long enough, but sometimes it isn't, or at least not within the time frame you have available. :-/
outline module and check child depth of contents
Hi,
I found that by going through the book module in the way you described, but also checking the child TOC setting for each parent book it appeared to be possible to have a TOC for each chapter eventually, but yes sometimes it did require starting again for some bizarre reason. Perhaps the default setting for TOC depth is not working. Hope that helps.
Simon
Possible solutions
I am not totally sure I understand what the requirement was; but for other people looking for something similar, the following two solutions might be relevant:
http://drupal.org/project/booktree
http://drupal.org/node/209336
Display entire book content in table of contents
I found a much cleaner solution to "Problem the first" here
http://drupal.org/node/614882
Essentially, if you include the following code in a module on your site it will display the entire book contents expanded in a book navigation block
@andystoks
@andystoks
This did not work for me, should i be using a hook block alter instead ?