Feb 142013

Sometimes you don’t want all those numbers on your pager. Or you don’t want the text ‘next’ etc. It is very easy to change those in a preprocess. This code changes the number of pages shown in the pager from the default down to 5, and changes the first, next, previous, last text to arrows.

function yourtheme_preprocess_pager(&$variables, $hook) {
  if ($variables['quantity'] > 5) $variables['quantity'] = 5;
  $variables['tags'][0] = '<<';
  $variables['tags'][1] = '<';
  $variables['tags'][3] = '>';
  $variables['tags'][4] = '>>';

Add this to your theme’s template.php and replace ‘yourtheme’ with your theme’s name.

  6 Responses to “Changing pager on Drupal 7”

  1. Great code. Worked like a charm.

  2. Great post. Thanks a lot.

  3. Thanks a lot – simple and efficient code!

  4. Search for quite a while and found many over complicated solutions, and then found this simple bit of code… Nice work!

  5. Thanks for this, man! Many sites are nothing but complicated with respect to pager theme override for Drupal 7.

  6. Great Code Thankyou 🙂

 Leave a Reply

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



This site uses Akismet to reduce spam. Learn how your comment data is processed.