Better Yii pagination

Hello guys,

I’m searching for a better pagination than default CLinkPager. If it’s possible to done with default Yii base (less modification), then will be even better.

I need something to look like this:

[First][< Previous][1][2]...[7][8][9][10][11]...[20][21][Next >][Last]

So if someone can recommend me how to do this I will appreciate it.

Thanks in advance


With minimal modification, you can make it look something like this:


There are two approaches:

First, you could modify the pager.css file, which is found in {YiiRoot}/framework/web/widgets/pagers/pager.css, where {YiiRoot} is the installation folder for Yii.

Change the css property for ul.yiiPager .first, ul.yiiPager .last to ‘display: inline’. (This property is around line 67), i.e.

ul.yiiPager .first, ul.yiiPager .last




The other approach, is copying the file specified above to another location, modifying it as described, then referencing it using the ‘cssFile’ property for ‘pager’ in the view, e.g.

'pager' => array(

        'cssFile' => Yii::app()->request->baseUrl . '/css/pager_mod.css',


assuming you’ve put the modified file (pager_mod.css) under your project’s css folder.

Generally, the second method is preferred since it avoids tampering with Yii’s base code.

All the best!


Thank you for your replay.

But unfortunately it’s not what I need.

I need something that will break first part of pagination and then add 3 dots ("…"), and then to display middle section and add numbers around current page like: [7][8][9][10][11], where [9] is current page, and after that to add 3 dots and after them last two page numbers. Here is an example how it looks: hxxp:// (just add hxxp with http, since I can’t post links).