Getting Page Number From Dataprovider

I need a pagination variable from my dataprovider in my controller action :

1.Current Page Number

How to get it ?


You are getting in the URL itself… check my url


here 3 represent 3 page in my gridview

2 for 2nd page :)


I can see it in url. How to get that in a variable from the dataprovider ?

Please can you tell me what are you trying to achieve. maybe it can help to check myself

I am trying to display the page number in the title of my page


you can get your current page number in controller inside actionadmin method using

following code


modelname_page … in above case my model name is programm

Hi Chandran,

I thought the same way. Because my link showed like this :

But when I tried to use($_GET[Controller_page]) , its always null. Is it because I am using ajax for it ? If yes, how to get the page number for ajax ?


i am using CGridview …



[/u][/color][color="#222222"][font="Consolas,"]my url also having same thing what you have … but i can access the Programm_page[/font][/color]


[/font][/color]are you using CGridview or Clistview ?


I think u r mising quotes



I did not miss the quotes inside my code. I am using ListView.

This is what I tried :

$page = isset($_GET['Controller_page']) ? $_GET['Controller_page'] : "hello";


echo "pagenumber".$page;

It always prints hello

Hi Chandran,

I tried disabling the ajaxUpdate by setting it to false and now its working. But I want to make it work with ajax ? Any idea ?


please can you copy your clistview code here … including ajax call

 $this->widget('zii.widgets.CListView', array(



		'ajaxUpdate'=>false,                  //Not working if i remove this





		'itemsCssClass'=>'hello-preview ',

		'htmlOptions'=> array(






		'afterAjaxUpdate'=>'function(id,data){ $(\' input \').rating({\'readOnly\':true}); hellohover();}',	


For your information,

cgridview and clistview are working using ajax…

Try it like this… below code is reference for getting value in controller

Do you mean the page number is getting printed in listview ajax also ?

This is my controller for your reference :

$page = isset($_GET['Hello_page']) ? $_GET['Hello_page'] : "hello";



		// build criteria object based on params

		$criteria = Hello::buildCriteria($keyword,$direction);

		// create dataProvider for result

		$dataProvider = new CActiveDataProvider(			 











Hello is my controller name


This is my code… its working perfect

In controller


	 * Lists all models.


	public function actionIndex()




		$dataProvider=new CActiveDataProvider('PhoOrganisation',










In view

<?php $this->widget('zii.widgets.CListView', array(



)); ?>

hello uwaisfariz getting current page number is easiest one lets me assume that $dataProvider is an cactivedataprovider’s object and you can get the current page number like this

$currrent_page = $dataProvider->getPagination()->currentPage;

echo $current_page;

note : current page is an zero based index so to print the human readable page number please add 1 to $current_page

Can you tell me what is the url you are getting when you go to second page via ajax ?

I tried it. Current Page value not getting changed.

what happened? how many pages you have?

I have around 10 pages. You can see my controller and view above. Using the method chandran suggested, it works if i disable ajax. Because the url gets changed to and $_GET gets the value. With ajax, its not working. The reason for it is because my url remains same for all the pages ( So $_GET will be null.