I have a simple view and would like to display the number of results. When I put a "result summary" in the header it did not appear, after some testing i found that views only show the summary when a pager is selected.

CommentFileSizeAuthor
#5 total_rows-6.x-2.x-1488694-5.patch485 bytesjstoller
#1 1488694.patch834 bytesdawehner
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dawehner’s picture

Status: Active » Needs review
FileSize
834 bytes

The problem is this row:

$total =$this->view->total_rows;
...
    if (!empty($total)) {
      $output .= filter_xss_admin(str_replace(array_keys($replacements), array_values($replacements), $format));
    }

As you see if total_rows will not be set, it simply doesn't display something. For some pager plugins though there is no count query runned, and so total_rows is not set. Here is a patch

k4v’s picture

this patch works fine for me

dawehner’s picture

Version: 7.x-3.x-dev » 6.x-3.x-dev
Status: Needs review » Patch (to be ported)

Thanks for the bug report and testing the patch! Committed to 7.x-3.x

Maybe this could be backported to 6.x-3.x

dan.mantyla’s picture

Works for me too! However I was hoping that $total would be the actual total in the database, not what was queried, i.e. if "Use pager: Display a specified number of items | 5 items" then $total will just be 5 items...

This may be nit-picking, but
$total = isset($this->view->total_rows) ? $this->view->total_rows : count($this->view->result);
can just be
$total = isset($this->view->total_rows) ? $this->view->total_rows : $count;

($count was defined on line 63 but I don't see it being used anywhere else)

jstoller’s picture

Issue summary: View changes
FileSize
485 bytes

Here's a patch for the 6.x-2.x branch, incase anyone else needs it.

izmeez’s picture

Status: Patch (to be ported) » Reviewed & tested by the community
Parent issue: » #2507847: Plan for Views v6.x-2.27 release
Related issues: +#2507839: Plan for Views v6.x-3.10 release

Patch in comment #5 applies without difficulty to latest views-6.x-2.26 and is a simple patch that was committed to views-7.x-3.x.
I have reviewed it and am marking it RTBC for 6.x-2.x

Chris Matthews’s picture

Status: Reviewed & tested by the community » Closed (outdated)

The Drupal 6 branch is no longer supported, please check with the D6LTS project if you need further support. For more information as to why this issue was closed, please see issue #3030347: Plan to clean process issue queue