Hi
I have been searching drupal.org for ways to customise the apperance of the book module's navigation.
What I would like to be able to do is display the tree-view (TOC) links above the content of book pages and keep the prev / up / next links at the bottom (but possible have the option to display them up top too).
So far I have been poking around with theme_book_navigation in book.module and have figured out how to disable certain parts of the book navigation. I know I can totally disable it by using the following function in my theme's template.php file:
/**
* Overrides the presentation of book nodes.
*/
function phptemplate_book_navigation($node) {
return '';
}
But I can't figure out how to get drupal to render book navigation above the content of book pages. I know it must be easy if you know how, but my PHP knowledge is limited.
Any guidance would be appreciated
Drupal 4.7 RC 2
PHP Template
Customised 'Friends Electric' Theme
Cheers
Jay
Comments
Use a custom module
I don't have time to write any code right now, but perhaps this suggestion could get you started:
You could write a custom module to add the book navigation block into the body of the node.
hook_nodeapi()is called when any node is viewed, and allows you to alter the contents of the node before it is displayed to the user. In your module, just test to see if the node being viewed is a book node. If it is a book node, then add the contents of the book block to the node body. This can be done by:$book_toc = book_block('view', 0);. This command returns an array into the variable$book_toc. The book navigation (TOC) can now by accessed by$book_toc['content'].All should be well.
This approach has two advantages:
Good luck!
- Corey
Out of time
Hey thanks for the advice
I understand (in theory) what you suggest but haven't enough time to have a go at implementing it just yet.
The site that I am working on needs to go live next week and seeing so I haven't ever attempted creating a custom module I don't think it's a good idea diving in just now ; )
What I am going to do is disable the TOC menu from book pages and leave the prev / up /next menu where it is (at the bottom).
I intend to convince my clients that using the book navigation block is the best way forward for their new site (because it just seems to work and will update itself when they create new child pages - which is a huge bonus)
Thanks again
Jay
Stumped on this question.
I'm assuming after 2 years someone must have figured out how to do this. Any suggestions for Drupal 6 users?
The ways I can think of off
The ways I can think of off the top of my head:
1. modify your theme templates.
2. Contemplate.
3. This script cleverly implemented.
Maybe even a mixture of the three...
- Corey
Thanks for the
Thanks for the suggestions...
Method 1 doesn't seem to work because the book navigation gets stuck into the $content variable by the theming engine. I can't see a way to separate the book navigation out or move it around.
Method 3 looks like it involves building a new menu from scratch. Seems like quite a headache to do something so seemingly trivial.
I will look into Contemplate to see if that helps. It sounds promising...
How can I build this custom
How can I build this custom module? Can you please help me with this same request? I too am trying to bring the links to child pages onto a right side nav bar.
A TOC on the right nav bar when any book is being views would be ideal. How can I do this?
Please help.
thanks
Navs
Create a new block-region
Hello Jay,
I had the same problem that you did with another module (one that I build myself).
Creating a new region for the module worked very well for me:
1 Create a new region (called "contenttop" for instance).
in
.info you should now have lines that look something like this (depending on which regions you want):
2 add the $contenttop variable to page.tpl.php.
in page.tpl.php you should find where the variable $content is printed and change "$content" to "$contenttop.$content".
the line should now look simething like :
print $contenttop.$content3 Clear the cache.
go to admin/settings/performance and click on the "clear cached data" button.
4 Move the module to this new region.
Another alternative...
Alternatively, you could use something like:
in your node template file (node-YOUR-TYPE-OF-NODE.tpl.php), instead of the usual:
Then, optionally, you'll just have to modify book-navigation.tpl.php to suit your needs.
Hope that helps some of you.
View Field incompatible with this approach
I am using a view field to embed a view of files into book pages, and this approach breaks the view field (the view is no longer displayed on the book page). I am using the view field module found here: http://drupal.org/project/viewfield Any ideas on how to make this node.tpl snippet work with a view field?
This solution works just fine
This solution works just fine for me. After I had some small troubles caused by not reading carefully enough everything works now according to my wishes.
For the protocoll:
<div class="content">...</div>- otherwise your attachments wont show up
Additionally you can customize the book-navigation.tpl.php according to your needs. Besides I edited the following lines in my node.tpl.php:
This causes Drupal only to show up author and creation date if the node contains a real article not only the navigation to subpages. of the book.
Drupal 7 Solution
This is a really old post, but thought I would share the Drupal 7 solution for any newbies coming along and looking for the solution to moving the book navigation block out of the bottom of the default main content region.
In your node.tpl.php file if you'll just want to find the line that looks similar to this:
<?php print render($content); ?>Then adjust it to look like this:
This will print the book_navigation separately wherever you want it to go.
marblegravy,
marblegravy,
Thank you so much!!!