Number of results in a Drupal View
Find the number of results in a view. Add this snippet to the header or footer of the view, depending on where you want the number of results to be displayed.
- $view = views_get_current_view();
- // execute view query
- // results are now stored as an array in $view->result
- $count = count( $view->result );
- print "Showing <b>$count</b> results";
If you liked this, you'll love my book, Master Drupal Module Development.
"..the must have drupal developers book"
Feeling stuck with Drupal 8 module dev?
Get the free 7 lesson course that will help you get started today without feeling overwhelmed.
- Create Drupal modules with just a few commands using the Drupal Console
- Create custom pages
- Create custom blocks
- Create admin forms
- Demystify routers and controllers
- Bonus material