Search code examples
drupaldrupal-viewsdrupal-7

Displaying a number of total filtered elements by exposed filters


I haven't seen working solution for Drupal 7 to do this. I have an exposed filters group which filters my views content to specified criteria and I'd like to display the number of found elements in a PHP block. I had working code for this :

<?php
  global $pager_total_items;
  print $pager_total_items[0] ;
?>

but it works ONLY in Bartik theme so here's my question: How can I display a number of total found/filtered elements in Drupal 7 views pager (any theme)..?


Solution

  • The solution for this is to put this code in the PHP block:

    $view = views_get_page_view();
    print $view->query->pager->get_total_items();
    

    and it works!