[Drupal] How to theme the pager created by Drupal views

| | 1 min read

When I was working on a website in Drupal 6 I wanted to theme the pager provided by views in a custom way. Finally I found a solution for the issue. If you also want to theme the pager in a View for your Drupal website you can follow the method below.

To theme a view pager first you have to find the theme.inc file inside views. Go to views module folder in your Drupal site and open theme.inc.

You can follow these steps

  1. Go to YOURSITE/sites/all/modules/views/theme
  2. Open theme.inc and search for function "theme_views_mini_pager"
  3. Copy the entire function.
  4. Now go to YOURSITE/sites/all/themes/YOURTHEME
  5. Open template.php file or create if you don't have the one.
  6. Paste the entire function.
  7. Now change the function name to "YOURTHEME_views_mini_pager"
  8. In my example I am changing the right and left double arrow ("«" and "»") to a text "previous" and "next". For this just replace the arrows with text.

For example:

$li_previous = theme('pager_previous', (isset($tags[1]) ? $tags[1] : t('«')), $limit, $element, 1, $parameters);


$li_previous = theme('pager_previous', (isset($tags[1]) ? $tags[1] : t('Previous')), $limit, $element, 1, $parameters);

Now clear all cache to see this is working. In my case I wanted to remove the double arrows and replace with texts "previous" and "next". You can also play with variables and themes in this function to theme pager in your own way. I hope this will help you, thanks!