Last updated October 14, 2009. Created on October 14, 2009.
Edited by nathan6137. Log in to edit this page.

Instead of using the usual page numbers for the pager (1, 2, 3, etc), I wanted to show the number of results i.e. 1-10, 11-20, 21-30, etc. After quite a bit of searching I finally figured out where to do the customizations and how to do it. By theming theme_pager() in includes/ I managed to get it to work. Maybe someone else will find this useful.

Just remember to change "themename" (in the function name) to the name of your theme, otherwise the override won't work.

*Override  themename_pager()
* Creates a numbered list e.g. 1-10 11-20... instead of the usual page number list i.e. 1 2 3 ...
function themename_pager($tags = array(), $limit = 10, $element = 0, $parameters = array()) {

$pager_page_array, $pager_total, $pager_total_items;
$page_prev = $pager_page_array[$element] - 1;
$page_curr = $pager_page_array[$element] + 1;
$page_next = $pager_page_array[$element] + 1;
$page_last = $pager_total[$element] - 1;

//Custom Label
$this_pg = $pager_page_array[$element]+1;
$last_pg = $pager_total[$element];  
$total = $pager_total_items[0];
$start = $page_curr*10 - 9;
$this_pg < $last_pg)
$end = $this_pg*10 ;
$end = $total;

$label = "Comments $start-$end of $total";
//end of custom label

if ($pager_total[$element] > 1) {
$output = '<div id="pagination" class="pager">';

        if (
$pager_page_array[$element]!=0) {
$output.= '<span class="pager-first pager-first-active"><a href="?page=0">First</a></span>';
$output.= '<span class="pager-previous pager-previous-active"><a href="?page='.$page_prev.'">Prev</a></span>';
        } else {
$output.= '<span class="pager-first pager-inactive pager-first-inactive">First</span>';
$output.= '<span class="pager-previous pager-inactive pager-previous-inactive">Prev</span>';


$output.= '<span class="pager-pagenumbers">'. $label .'</span>';

        if (
$page_curr!=$pager_total[$element]) {
$output.= '<span class="pager-next pager-next-active"><a href="?page='.$page_next.'">Next</a></span>';
$output.= '<span class="pager-last pager-last-active"><a href="?page='.$pager_total[$element].'">Last</a></span>';
        } else {
$output.= '<span class="pager-next pager-inactive pager-next-inactive">Next</span>';

$output.= '<span class="pager-last pager-inactive pager-last-inactive">Last</span>';

$output.= '</div>';

Looking for support? Visit the forums, or join #drupal-support in IRC.


ari-meetai’s picture

Remember to change these lines:

//Custom Label
$this_pg = $pager_page_array[$element]+1;
$last_pg = $pager_total[$element];
$total = $pager_total_items[0];
$start = $page_curr*$limit - ($limit -1);
if($this_pg < $last_pg)
$end = $this_pg*$limit ;
$end = $total;

for the counter to go ok.

I still think the pager should be "objectified" and more available somehow. It can be hotter like in


giozzz’s picture

hello! how can i simply change the pager button titles? like i want to change previuos, next last into other texts? is there a way to do that?????? I can find nothing! thanks