On this page
Custom pager theming examples
Last updated on
30 April 2025
This is a page of example code and templates for custom pagers. Please add your own!
Using these examples
Theming a custom pager can involve making several changes to your theme:
- creating a function phptemplate_preprocess_custom_pager in your theme's template.php file
- creating template files in your theme folder, eg. custom-pager.tpl.php
First and Last links
In template.php:
function phptemplate_preprocess_custom_pager(&$vars) {
// if we're at the end, the nav_array item for this (eg first) is NULL;
// no need to compare it to current index.
$vars['first'] = empty($vars['nav_array']['first']) ? '' : l('first', 'node/' . $vars['nav_array']['first']);
$vars['last'] = empty($vars['nav_array']['last']) ? '' : l('last', 'node/' . $vars['nav_array']['last']);
}
Add a custom-pager.tpl.php:
<ul class="custom-pager custom-pager-<?php print $position; ?>">
<li class="first"><?php print $first; ?></li>
<li class="previous"><?php print $previous; ?></li>
<li class="key"><?php print $key; ?></li>
<li class="next"><?php print $next; ?></li>
<li class="last"><?php print $last; ?></li>
</ul>
Help improve this page
Page status: Not set
You can:
You can:
- Log in, click Edit, and edit this page
- Log in, click Discuss, update the Page status value, and suggest an improvement
- Log in and create a Documentation issue with your suggestion