#Yii_tips: How to the get current page in CListView from partial rendering view?

Updated July 12, 2013 ‚óŹ 1,872 views

There are special variables available to the partial rendering view in CListView. These are:

  • $data - the current object or hash being rendered
  • $index - the zero-based index of the item being rendered (0, 1, 2, ...)
  • $this - the owner of the widget, usually the calling controller
  • $widget - the CListView widget itself

From partial rendering view, you can access currentPage, pageCount, count of data in the current page. Here's how you can get it:

$pageCount = $widget->dataProvider->pagination->pageCount;
$currentPage = $widget->dataProvider->pagination->currentPage + 1;
$dataCount = count($widget->dataProvider->data);


Sort by Best Controversial New

Welcome to dizkover ram66. This is a pretty good Yii tip. Thanks for sharing!

master_yii · 7 years ago
permalink · reply (1)

@master_yii: Thanks..

ram66 · 7 years ago
permalink · reply

Very helpful Yii tip! This actually helped me because i've trying to figure out how to properly do partial render of a table in CListView.

Prakash1 · 7 years ago
permalink · reply (0)

Our Terms of Use and Privacy Policy have changed.
By continuing to use this site, you are agreeing to the new Privacy Policy and Terms of Service.