How to create a custom CListlView widget in yii

I am developing my web application in a Yii framework. I do not have enough experience in the structure of Yii. I want to make a presentation for the index post page. Yii provides a CListView for this, but I want to make some adjustments on this.

+4
source share
2 answers

You can expand the widget using the following steps:

Copy CListView.php from / (yii root) / framework / zii / widgets to / (application root) / protected / widgets

Rename the BineshListView.php File

Open BineshListView.php. Add this before class declaration.

Yii::import("zii.widgets.CListView"); 

Change the first line of the class declaration to:

 class BineshListView extends CListView { ... 

You now have your own BineshListView class that you can customize. To use it in a view, you can call it just like a CListView

 $this->widget('application.widgets.BineshListView', array( 'data'=>$model, etc... ) ); 

I add that BineshListView inherits all the properties and methods of CListView. Therefore, if you do not need to configure a property or method and you want to use the original CListView behavior, you can remove the property or method from BineshListView.

+6
source

you do not need to configure ClistView. just make changes to the partial view file. which is called by ClistView.

 <?php $this->widget('zii.widgets.ClistView',arrray( 'dataprovider'=>$your-data-provider, 'view-file'=>'custom-view-file' )); 

? >

make changes to the custom-view file. make sure the user view file is in the same views folder for the controller.

+3
source

All Articles