Submitted by greggles on
Continuing on from the project I just mentioned...I wanted to remove the list of pages (which is analogous to a table of contents) from the book pages. On this particular site I'm using the book block on the right hand side, so having this information on the bottom of top level page makes for duplication of links and just seems plain funny. Below is the relevant diff -u on the subject:
Edit: This is actually a really bad idea. See the comments below for the right way to do it for Drupal 6.
@@ -469,9 +469,9 @@ if ($node->nid) { $output .= ''; - /*if ($tree = book_tree($node->nid)) { + if ($tree = book_tree($node->nid)) { $output .= ''. $tree .''; - }*/ + } if ($prev = book_prev($node)) { $links .= '';
Category:
People Involved:
- Log in to post comments
Comments
JasonQ replied on Permalink
how does this work?
I'm having trouble trying to do the same thing on a Drupal site I'm developing. I'd like to remove the Table of Contents that is always generated.
I was glad to find this page, but I can't seem to figure out how to implement the code above you've suggested. I quite a beginner in these things and could really use some more specific instructions.
I've been trying to make adjustments to the book.module file, based on your code, but I don't seem to be able to get it right.
Any advice would be greatly appreciated.
Thanks!
really bad idea
This is actually a really bad idea. I'm not sure how to remove the table of contents without hacking the book module, but this is the wrong way to do it, I assure you :(
Vint Falken replied on Permalink
remove book links
Warning! This is at own risk... (It worked for me. For now...)
(for drupal 6.1)
<?php if ($tree || $has_links): ?>" class="book-navigation">
<?php if ($prev_url) : ?>
<?php print $tree; ?>
<?php if ($has_links): ?>
" class="page-previous" title="<?php print t('Go to previous page'); ?>"><?php print t('â¹ ') . $prev_title; ?>
<?php endif; ?>
<?php if ($parent_url) : ?>
" class="page-up" title="<?php print t('Go to parent page'); ?>"><?php print t('up'); ?>
<?php endif; ?>
<?php if ($next_url) : ?>
" class="page-next" title="<?php print t('Go to next page'); ?>"><?php print $next_title . t(' âº'); ?>
<?php endif; ?>
<?php endif; ?>
<?php endif; ?>
If this turns out to be not a very smart thing to do, please notify me! ;)
close to right...here's the "Drupal way" to do it
This is almost the right answer. Basically (as my warning above states) what you want to do is not edit the original code, but use Drupal's override system. When you edit the original code then you have to be sure to re-apply the change whenever you update Drupal (and you are going to update Drupal when Drupal6.2 is release right...
So...by using a theme override, you can apply this in a way which will still work after you've upgraded your site.
Anonymous replied on Permalink
Works great and it is the drupal way
TVM greggles. I implemented your suggestion to good effect:
I copied book-navigation.tpl.php to my theme directory, and edited it there. I actually encased all the content in the file as follows:
<?php /*
:
:
*/?>
This got rid of ALL the navigation content in the book block itself, which is what I wanted - I already had the book navigation block enabled (in left sidebar) and that's all i wanted to present to the user.
Regards,
CdeB
Vint replied on Permalink
Hmmm... yeey thanks...
Yeey. It worked. I thus restored the original file in the drupal module and used the theme override. Thank you for the advice! (And do update your blogposts, when you find a solution for a problem, it helps the folks googling for the exact same problem, and thus solution... ;))
Thanks again,
Vint
nicks replied on Permalink
Removing Table of Contents from Drupal 5 Book
To implement this in Drupal5, you need to override the "theme_book_navigation" method in your template.php file. Copy this from "book.module", and replace "theme" with your theme name as per usual.
To remove the tree, simply comment out this line:
$tree = book_tree($node->nid);
There is however one gotcha. Drupal's link function strips out the text of the navigation links because it doesn't like the arrow symbols this uses. Simply change them to "<" and ">" and it should work without a problem.
OUVYT &raqu... replied on Permalink
Pingback
Anonymous replied on Permalink
Can I make out with
Can I make out with you?
Thanks for the fix.
Chris replied on Permalink
THank you!
Thank you your 'right way' to do it works perfectly for me!
Setting up a Dr... replied on Permalink
Pingback
Havanapar replied on Permalink
What if we need to make the contrary?
the Table of Contents shows us the Title field of the book pages...what if we want to show another fields instead of the title in the TOC?
Any Clue?
Thanks
Hava