My goal is to push the book navigation section (which I've rethemed) above the main content of the node. However it seems that the navigation is forced below. I've started this as a support request, assuming that "everything is themeable", maybe I just need enlightening.
Having been called from node_view(), book_nodeapi() adds the navigation section to the $node->content array with a weight of 100.
$node->content['book_navigation'] = array(
'#value' => theme('book_navigation', $node),
'#weight' => 100,
);
Following the code, there appears to be no-where else to hook in until drupal_render which gets an array containing the content and navigation on separate elements. print_r shows:
<?php
[content] => Array (
[body] => Array (
[#value] => <p>This is the content of the page</p>
[#weight] => 0
)
[book_navigation] => Array (
[#value] => <div class="book-navigation">...etc...</div>
[#weight] => 100
)
)
?>
Which is then rendered:
/* render each of the children using drupal_render and concatenate them */
if (!isset($content) || $content === '') {
foreach ($children as $key) {
$content .= drupal_render($elements[$key]);
}
}
So, I can't seem to control this order anywhere. Have I missed something? Is there room for improvement?
My best shot seems to be:
- Override theme_book_navigation and return ''
- Use CSS to hide the book navigation
- Use mysitemodule_nodeapi to replicate book navigation, but with a negative weight (to rise above the content)
Cheers for any help
Simon
Comments
Comment #1
simeFWIW, my strategy works, but it feels a little hacking as I'm essentially duplicating a lot of code out of book.module
Comment #2
simeoops. The individual parts are all there on the $node in node.tpl.php
Comment #3
Roi Danton commentedIn past I've hacked the book module directly...
...which isn't quite comfortably. So I'm searching for alternatives. But I don't understand how you're able to change the position of book_navigation within node.tpl.php. Obviously changing the weight of $node->content['book_navigation'] inside the tpl doesn't work.
In a perfect world one would be able to change the weight of book navigation like the title or other cck fields. ;)
Comment #4
Roi Danton commentedComment #5
elpino commentedI found another way to do as explained in this comment http://drupal.org/node/59881#comment-1831242
It just requires to edit your node.tpl.php template, instead of using the node given variable $content
just print
Comment #6
aotus commentedAdding this:
in node.tpl.php worked for me by putting the nav both at the top and bottom. It looks okay on large book pages, but a bit overcrowded when a book page has less text. I tried the unofficial 'booktopnav' module http://coredogs.com/article/book-top-navigation-module-drupal which tries to resolve this, but I couldn't get that to work - any suggestions?
Comment #7
aotus commentedNote also that while the #6 above duplicates the prev/next/up navigation nice and simple, the table of contents (TOC) are also displayed twice - this looks really messy on book pages where there is only a little or even no other book text: just the TOC appearing twice. Any suggestions how to display the prev/next/up navigation on top and bottom of pages, but not the TOC?
Comment #8
kars-t commentedHi
I am closing this issue to clean up the issue queue. Feel free to reopen the issue if there is new information and the problem still resides. If not please make sure you close your issues that you don't need any more.
Maybe you can get support from the local user group. Please take a look at this list at groups.drupal.org.