I'm using Search API along with Facet API to administer a search for my products. I'm also overriding the search with a view. I'm looking for some method of counting the search results and displaying this information. For example, at the top of the search results page I want text to be displayed that reads something like "Showing 1 - 16 of 39,352 Results". I've read somewhere that views is able to do this easily, the problem is that I'm using facets and I don't think the results count from views will work together with applied facets. Can someone give me a solution or at least an idea?

3 Answers 3


In the view that I'm using to override my search results, I added "Global: Result summary" to the views Header and it seems to be working with the facets. Thanks.


There is already a module for this - https://drupal.org/project/views_record_count Provides same functionality you are looking for.

Some details from the module's project page:

This module will add some additional functionality in views. You can see the record count in views header/footer if you have chosen pager. You will see record count option as well when you edit the view. If you setup some overridden values in you display, it work with them also. Default message region is footer. You can change it as well.


By using the below code, you can do that, It will display like this Showing 1-10 of 130 results. on your result page.

Put this code in the page.tpl or views Header and set the input filter as PHP code in your view.

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])
  • Thanks for helping. I put the code in the views Header and am getting the following error: "Notice: Undefined property: view::$pager in eval() (line 4 of C:\xampp\htdocs\drupal\modules\php\php.module(80) : eval()'d code)."
    – user22939
    Commented Nov 11, 2013 at 5:00
  • Never mind. I added "Global: Result summary" to the views header and it seems to be working with the facets. Thanks.
    – user22939
    Commented Nov 11, 2013 at 5:20
  • @user22939, I was writing the same in my answer, but I got your comment before my posting so I have to skip my answer. Commented Nov 11, 2013 at 5:21
  • @user22939 then add your answer, it will help the future visitors.
    – Bala
    Commented Nov 11, 2013 at 5:25

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.