Already had this for Drupal 5 and 6 here.
This is the code using hook_views_pre_render() which also works in Drupal 7 and Views 3.
Borrowed from jeff geerling.
<?php
/**
* Implements hook_views_pre_render().
*/
function MYMOD_views_pre_render(&$view) {
if ($view->name == 'admin_content_node') {
$output = '';
$from = ($view->query->pager->current_page * $view->query->pager->options['items_per_page']) + 1;
$to = $from + count($view->result) - 1;
$total = $view->total_rows;
$output .= '<div class="views-result-count">';
if ($total <= $to) {
// If there's no pager, just print the total.
$output .= $total . ' results.';
} else {
// Otherwise, show "Showing X - X of XX results."
$output .= 'Showing ' . $from . ' - ' . $to . ' of '. $total . ' results.';
}
$output .= '</div>';
$view->attachment_before = $output;
}
}
?>This is the company blog of
Drupal specialist Merge.nl.
We are located in Tilburg (Netherlands) and build websites using Drupal. More about us.
Content on this blog is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Netherlands License.
