#Yii_tips: How to the get current page in CListView from partial rendering view?
Updated July 12, 2013 ● 1,933 views
Yii channell is about Yii PHP Framework. Yii is a free, open-source Web application development framework written in PHP5 that promotes clean, dry design and encourages rapid development. It works to streamline your application development and helps to ensure an extremely efficient, extensible, and maintainable end product.
If you are a fellow Yii developer, join us! Do not hesitate to share your ideas. If you have a Yii product, you are welcome to share your creation here.
Check out Yii Framework official website.
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);
Welcome to dizkover ram66. This is a pretty good Yii tip. Thanks for sharing!
master_yii · 11 years agopermalink · reply (1)
@master_yii: Thanks..
ram66 · 11 years agopermalink · 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 · 11 years agopermalink · reply (0)