The example in this article describes the custom paging implementation method of Yii view operation. Share it with everyone for your reference, the details are as follows:
1. When the view file calls cgridview, clistview, call the custom paging method
<?php $this->widget('zii.widgets.grid.CGridView', array( 'id'=>'news-grid', 'dataProvider'=>$model->search(), 'filter'=>$model, 'template'=>'{items}{summary}{pager}', 'selectableRows'=>2, 'pager'=>'ZPager', 'summaryText'=>'页数:{pages}/{page}页', 'columns'=>array( array( 'class'=>'CCheckBoxColumn', 'footer'=>'<button onclink="deleteAll()">button</button> <button onclink="refashAll()">button</button>', 'footerHtmlOptions'=>array('colspan'=>5), 'selectableRows'=>2, ), 'id', array('name'=>'title', 'htmlOptions'=>array('width'=>'20%'), 'value'=>'mb_substr($data->title,0,10,"utf-8")', ), array('name'=>'content', 'htmlOptions'=>array('width'=>'20%'), 'value'=>'mb_substr(strip_tags($data->content),0,10,"utf-8")', ), array('name'=>'type', 'value'=>'News::model()->getNewsType($data->type)', ), 'user', array('name'=>'status', 'value'=>'News::model()->getNewsStatus($data->status)', ), array( 'class'=>'CButtonColumn', 'buttons'=>array( 'view'=>array('visible'=>'false'), //'delete'=>array('click'=>'true'), ), ), ), ));
2. Copy the base paging class file and modify it to become Copy your own paging method
framework/web/widgets/pagers/CListPager.php and rename it to protected/components/zpager.php. Modify the class name
framework/web/widgets/pagers/ pager.css Copy the corresponding style file to protected/components/css/pager.css
Modify the css loading directory of zpager.php
public static function registerCssFile($url=null) { if($url===null) $url=CHtml::asset(Yii::getPathOfAlias('application.components.css.pager').'.css'); Yii::app()->getClientScript()->registerCssFile($url); }
3. By modifying the Css style file, you can also modify the generated List program to achieve the purpose of modifying classification.
I hope this article will be helpful to everyone’s PHP program design based on the Yii framework.
For more articles related to Yii view operation custom paging implementation methods, please pay attention to the PHP Chinese website!