Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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.
Comment | File | Size | Author |
---|---|---|---|
#5 | total_rows-6.x-2.x-1488694-5.patch | 485 bytes | jstoller |
#1 | 1488694.patch | 834 bytes | dawehner |
Comments
Comment #1
dawehnerThe problem is this row:
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
Comment #2
k4v CreditAttribution: k4v commentedthis patch works fine for me
Comment #3
dawehnerThanks for the bug report and testing the patch! Committed to 7.x-3.x
Maybe this could be backported to 6.x-3.x
Comment #4
dan.mantyla CreditAttribution: dan.mantyla commentedWorks 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)Comment #5
jstollerHere's a patch for the 6.x-2.x branch, incase anyone else needs it.
Comment #6
izmeez CreditAttribution: izmeez commentedPatch 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
Comment #7
Chris Matthews CreditAttribution: Chris Matthews as a volunteer commentedThe 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