5

Found this answer, show amount of results for exposed filter and this answer.

However, my issue is that i'm trying find the total number of results after executing an exposed filter.

Views calc looks like it only returns the count of results from a single result not an exposed filter result. Or if i'm wrong please correct me.

Anyways, the question: How do you find the total number of results from an exposed filter?

Desired result:

  • Complete an exposed result form
  • return "x number of results found" as a block
8

I'm using Views 3.7 in Drupal 7 right now and finally found out you simply can add a result summary Global: Result summary to the header/footer.

0

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 Header and set the input filter as PHP code in your view.

<?php
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])
  );
}
?>
  • Could i just create a custom module and place it in there somehow? – chrisjlee Sep 18 '13 at 16:42
  • Why do you want to create custom module, just put this code in header of the view. It will display in the result page. – Bala Sep 18 '13 at 17:03
  • 4
    I want to avoid using php filter; as it's a security issue. – chrisjlee Sep 18 '13 at 17:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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