Last updated August 29, 2013. Created by dman on April 20, 2011.
Log in to edit this page.

If using the pager, that can display an indication of the number of items. But it you want an all-in-one list, it's often handy to have a sum at the bottom.

Use a PHP snippet

If you are happy to open up php format, edit your view and insert this code from faost

<?php
$current_view
= views_get_current_view();
print
count($current_view->result);
?>

into the footer area.

Do it in one of your own modules

If you prefer to keep code in the modules, and not use PHP format in the UI, try something like this

<?php
/**
* HOOK_views_pre_render()
* When rendering one of our own views, insert a count into the footer.
*/
function MODULENAME_views_pre_render(&$view) {
 
$view->style_plugin->display->handler->options['footer'] = count($view->result) . " items";
 
$view->style_plugin->display->handler->options['defaults']['footer'] = FALSE;
}
?>

Special modules

There are a couple of modules built to handle this also. It may be excessive to enable a whole module for something that can be done in such a small snippet, but:
views_calc Seems worth it.
views_record_count does the same.

Looking for support? Visit the Drupal.org forums, or join #drupal-support in IRC.