Limit Number On Clinkpager

For example, we have thousands of data which we will show in Cgridview automatically CLinkPager appear 1 2 3 4 5 6 7 8 9 10 and so on… How can I show 5 link number only ( 1 2 3 4 5 …) ?

Thanks for sharing experience with yii.

You’d have to extend CLinkPager and override it’s createPageButtons method.

Hi, Dan S.K thanks for advance, I try your code not work properly, finally I found a solution.

  1. I extend CLinkPager as Dan S.K suggest me but its simple code

class MyLinkPager extends CLinkPager


	public $maxButtonCount=5;

	public $cssFile = 'css/newpager.css'; // i want to show first and last link


  1. create new css file I put in css folder, I just copy all css code located in [font="Courier New"]/yii/framework/web/widgets/pagers/pager.css[/font] [font="Arial"]into[/font] [font="Arial"]newpager.css, for more go here

  2. register MyLinkPager class in CGridview



    	'pager' => array(

        	'class' => 'MyLinkPager',





Sorry, I thought you asked how to turn it into smth like 1 … 6 7 8 9 … 20

But in your case you could just pass it in the pager property and it’d override the default value

    'pager' => array(

               'maxButtonCount' => 5


Ok Dan, Thanks a lot for your new solution, I just found out now :D