From 6544db48dc905726309114a3416adaeb862999b1 Mon Sep 17 00:00:00 2001 From: Carsten Brandt Date: Sun, 13 Oct 2013 21:43:51 +0200 Subject: [PATCH] consistent summary display for ListView and GridView Total 0 items. when list is empty. and showing x out of x for n>0 and paging on. --- framework/yii/widgets/BaseListView.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/framework/yii/widgets/BaseListView.php b/framework/yii/widgets/BaseListView.php index d4647ff..8e827d6 100644 --- a/framework/yii/widgets/BaseListView.php +++ b/framework/yii/widgets/BaseListView.php @@ -132,14 +132,14 @@ abstract class BaseListView extends Widget public function renderSummary() { $count = $this->dataProvider->getCount(); - if (($pagination = $this->dataProvider->getPagination()) !== false) { + if (($pagination = $this->dataProvider->getPagination()) !== false && $count > 0) { $totalCount = $this->dataProvider->getTotalCount(); $begin = $pagination->getPage() * $pagination->pageSize + 1; $end = $begin + $count - 1; $page = $pagination->getPage() + 1; $pageCount = $pagination->pageCount; if (($summaryContent = $this->summary) === null) { - $summaryContent = '
' . Yii::t('yii', 'Total 1 item.|Showing {begin}-{end} of {totalCount} items.', $totalCount) . '
'; + $summaryContent = '
' . Yii::t('yii', 'Showing {begin}-{end} of {totalCount} item.|Showing {begin}-{end} of {totalCount} items.', $totalCount) . '
'; } } else { $begin = $page = $pageCount = 1;