Drupal: How To Remove Navigation From Book
When you view a node of ‘book’ type, you see a book navigation at the bottom: child nodes, previous and next nodes, and one level up node. We need to get rid of this navigation.
Solutions:
Drupal 6
- Исправление шаблона навигации модуля book
- Вариант, который будет работать после обновления версии Друпал.
Modify navigation template of book module
You could modify a template in system module folder. The disadvantage of this method is that you should make the same changes every time after Drupal has been upgraded.
- Move to …/drupal/modules/book
- Find book-navigation.tpl.php and create a backup copy in the same folder (book-navigation.tpl.php-backup)
- Open a file and remove all code there:<?php if ($tree || $has_links): ?>
<div id=”book-navigation-<?php print $book_id; ?>” class=”book-navigation”>
<?php print $tree; ?>
<?php if ($has_links): ?>
<div class=”page-links clear-block”>
<?php if ($prev_url) : ?>
<a href=”<?php print $prev_url; ?>” class=”page-previous” title=”<?php print t(‘Go to previous page’); ?>”><?php print t(‘‹ ‘) . $prev_title; ?></a>
<?php endif; ?>
<?php if ($parent_url) : ?>
<a href=”<?php print $parent_url; ?>” class=”page-up” title=”<?php print t(‘Go to parent page’); ?>”><?php print t(‘up’); ?></a>
<?php endif; ?>
<?php if ($next_url) : ?>
<a href=”<?php print $next_url; ?>” class=”page-next” title=”<?php print t(‘Go to next page’); ?>”><?php print $next_title . t(‘ ›’); ?></a>
<?php endif; ?>
</div>
<?php endif; ?>
</div>
<?php endif; ?> - Check if you get the required result. Restore a file from the backup copy if you don’t. Enjoy if you do
Method that will work even after upgrading Drupal
You can use redefining to apply this method. This way, it would work even after you upgrade Drupal.
- Open drupal/modules/book
- Copy book-navigation.tpl.php to a folder with your current theme (e.g.: sites/all/themes/theme_name/)
- Modify new book-navigation.tpl.php and remove the following code:
<?php print $tree; ?>
- You won’t see these changes because of a new theme registry – you should open example.com/admin/settings/performance and click “Clear cached data” below the page.
- Ready
Drupal 5
You should redefine “theme_book_navigation” in your template.php for Drupal 5.
Copy this function from “book.module” file and replace “theme” to your theme name.
To remove a tree, comment this line:
$tree = book_tree($node->nid);
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.
Enjoy!