create custome widget with pagination

hi, everybody !!

i want to create my own widget to display some information on home a slider i want to display some information with a pagination.

Could you guys help me out how could i approach for this kind of widget.because i am a beginner in yii and done have a to much idea about pagination of yii…!!

thanks in advance…!!

You should create class(MyWidget) and extend from CWidget. it must be in components folder. You may see yii’s blog. There are examples of using Widgets and Portlets.

yes elbek m doing same thing …but a confusion is that how could i show represent data in my view file…i have render a view with data provider…but my data i didn’t get any data in ma view file…

this is my code for my widget code:-



  • this class is create for a custom

  • widget.which will display a home page slider…

  • @author:jayant

  • @date:2011-04-04


class Slider extends CWidget {

public function run() {

 &#036;rows=new CActiveDataProvider('User',array('pagination'=&gt;array('pageSize'=&gt;5)));







when i run this code and var dump an $user array in view file…then i didn’t get appropriate result which i am exacting like user info from table.

i am trying to show this information with a pagination…but i am not so well yet with yii so i can find out a exact way to do it…

public function run()


  $dp=new CActiveDataProvider('User',array('pagination'=>array('pageSize'=>5)));



In the view you can access the dataprovider like this:

$user->data // an array of CActiveRecord objects

$user->pagination // a CPagination object

$user->sort // a CSort object

More information in the API reference.


thanks for your reply tri…!!!

its work great for me…!!! ::)

i’ve done this work…but not satisfied with it…because there is a ajax pagination in this widget then its look good …and i am also willing this…does anybody tell me how could i apply ajax pagination built in yii…!!

thanks in advance…!!!

Only the lucky few know how to do ajax pagination in yii. The rest of us wallow in confusion and hope for a clear answer somewhere.

Fortunately Yii is an open source framework, so you can find good examples of implementation of ajax pagination in the code of zii widgets. You can even copy&paste code snippets as necessary.