1

Using Drupal 7.

I've got several views (most of which listing articles which have been posted) that paginate and I'd like to add;

<link rel="prev" href="http://example.com/recent-articles?page=0" />
<link rel="next" href="http://example.com/recent-articles?page=2" />

links to them.

How do I do this? A module is preferred, changing the php files would preferably be avoided.

Things I've tried:

2
  • have you checked pager options in views – TBI Infotech Aug 7 '14 at 10:11
  • Yes, as stated in the question - I've tried the views controls themselves. This includes the controls available in the specific view. – Chor Hatara Hud'u Keturi Aug 7 '14 at 10:14
0

You just need to override theme_pager_previous() and theme_pager_next() (easiest to do in your theme):

function MYTHEME_pager_previous($vars) {
  $text = $variables['text'];
  $element = $variables['element'];
  $interval = $variables['interval'];
  $parameters = $variables['parameters'];
  global $pager_page_array;
  $output = '';

  // If we are anywhere but the first page
  if ($pager_page_array[$element] > 0) {
    $page_new = pager_load_array($pager_page_array[$element] - $interval, $element, $pager_page_array);

    // Changes from core function start here.
    $attributes = array('rel' => 'prev');

    // If the previous page is the first page, mark the link as such.
    if ($page_new[$element] == 0) {
      $output = theme('pager_first', array('text' => $text, 'element' => $element, 'parameters' => $parameters, 'attributes' => $attributes));
    }
    // The previous page is not the first page.
    else {
      $output = theme('pager_link', array('text' => $text, 'page_new' => $page_new, 'element' => $element, 'parameters' => $parameters, 'attributes' => $attributes));
    }
  }

  return $output;
}

And the same thing for pager_next.

2
0

It seems like there is a contrib module outside of D.O. that does the trick.

https://github.com/nlisgo/nextprev_links

Have you already tried this one?

0

I had the similar issue of combining multiple views and give the pager so they all combined, and can accessible by the pager. I have asked previously on DA and here is the link just see the detail of answer and question you will automatically will get idea how you can do it.

How to add pager at the bottom which allow shifting between views?

Basically, you can do by this views, all your articles in one views and add new display page and go increasing offset +1 in pager for subsequent pages. Just follow the answer you will get idea. And lastly add the pager as described in the answer to combine all.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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