Drupal: .htaccess Access Deny
August 21, 2014 – 7:59 am | No Comment

In this article I will tell how to forbid access to certain resources for some clients. The instructions will include descriptions of different directives.

Read the full story »
CSS Templates

Contain reviews and news about CSS Templates.

Freebies

Contain freebies such as icons, graphics, headers and images for your websites.

Fun Stuff

Contains other fun stuff for entertainment or interesting site showcase.

How-To

Contain technical elaborations on some specific workarounds or common tweak.

Joomla Templates

Contains reviews and news about Joomla templates.

Home » How-To

Drupal: How To Remove Navigation From Book

Submitted by on January 3, 2012 – 9:41 amNo Comment

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 Smile

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 Smile

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!

Leave a comment!

Add your comment below, or trackback from your own site. You can also subscribe to these comments via RSS.

Be nice. Keep it clean. Stay on topic. No spam.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

This is a Gravatar-enabled weblog. To get your own globally-recognized-avatar, please register at Gravatar.