I have some entities queried from an external solr server using custom code and Search API, and I'm listing them 10 per page.

I have created a pager for the page using pager_default_initialize() and theme('pager').

I wanted to insert a text into the pager div that says "Showing X - Y of Z results". I can do this manually by overriding the theme_pager() function, but I was wondering is there a drupal native function or some setting which you can pass to theme_pager that does this?

I suppose in short I want the Views 3 equivalent of "Full pager", instead at the moment I'm only able to produce the "Mini" pager.

1 Answer 1


In views you can use the below php function and place it in header with php filter

global $pager_page_array, $pager_total_items, $pager_total;
$my_view = views_get_current_view();
$items_per_page = $my_view->pager['items_per_page'];
if ($pager_total[0] == 1) {
  echo t('Showing <b>!pager_total_items</b> results',
    array('!pager_total_items' => $pager_total_items[0])
} else {
  $start = 1 + ($pager_page_array[0] * $items_per_page);
  $end = (1 + $pager_page_array[0]) * $items_per_page;
  if ($end > $pager_total_items[0]) $end = $pager_total_items[0];
  echo t('Showing !start-!end of <b>!pager_total_items</b> results',
    array('!start' => $start, '!end' => $end, '!pager_total_items' => $pager_total_items[0])

See the below is result

enter image description here

  • Thanks, but it's not a views view, it's a custom pager on a node.
    – Beebee
    Jul 5, 2013 at 10:39
  • 1
    Works well, you could also add this as a variable in a hook_preprocess_views_view() and override the view's template to avoid having to use the PHP filter Jul 15, 2015 at 0:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.