3

I want to have Next and Back buttons for nodes within a book.

What is the easiest way to achieve this?

2
  • 1
    nodes in a book already have previous and next links, along with Up ... cant you theme those to your needs ?
    – tenken
    Commented Feb 6, 2013 at 16:12
  • yes, what is the best way to theme them?
    – Bulat
    Commented Feb 6, 2013 at 16:14

2 Answers 2

1

ok, this can be achieved by overriding of modules\books\book-navigation.tpl file. Copy this file to your Theme and change following:

 <?php if ($has_links): ?>
    <div class="page-links clearfix">
      <?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; ?>

to:

<?php if ($has_links): ?>
    <div class="page-links clearfix">
      <?php if ($prev_url): ?>
        <a href="<?php print $prev_url; ?>" class="page-previous" title="<?php print t('Go to previous page'); ?>"><?php print t('Back') ?></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 t('Next'); ?></a>
      <?php endif; ?>
    </div>
    <?php endif; ?>
-1

You could try one of the following modules: http://drupal.org/project/prev_next or http://drupal.org/project/custom_pagers. We've been using the Prev/Next module for a while in a project.

5
  • this is sort of interesting, but custom_pages is only for D6 and prev_next gets next node by node id, not by it's location in a Book.
    – Bulat
    Commented Feb 6, 2013 at 15:50
  • custom_pages has a dev drupal 7 version, might look into that, as it uses views. But I'm not sure what you mean by a book, is it a view? taxonomy? More context would help.
    – mns
    Commented Feb 6, 2013 at 16:09
  • Book is a module in core that allows to join nodes in hierarchical structure. It also adds navigation links to Up/Next/Prev, but text in the link to a next node has a name of the node, while I just need "Next" button/link.
    – Bulat
    Commented Feb 6, 2013 at 16:13
  • Well, you should have been more clear on that! You can just theme the existing ones (theme is book_navigation).
    – mns
    Commented Feb 6, 2013 at 16:25
  • well there is books tag on the question
    – Bulat
    Commented Feb 6, 2013 at 16:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.