Drupal Technical
[Drupal] How to theme the pager created by Drupal views
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
- Go to YOURSITE/sites/all/modules/views/theme
- Open theme.inc and search for function "theme_views_mini_pager"
- Copy the entire function.
- Now go to YOURSITE/sites/all/themes/YOURTHEME
- Open template.php file or create if you don't have the one.
- Paste the entire function.
- Now change the function name to "YOURTHEME_views_mini_pager"
- 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);
To
$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!