Home> php教程> PHP开发> body text

Yii view operation custom paging implementation method

高洛峰
Release: 2016-12-30 16:11:10
Original
1570 people have browsed it

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

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'=>' ', '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'), ), ), ), ));
Copy after login

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); }
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template
    About us Disclaimer Sitemap
    php.cn:Public welfare online PHP training,Help PHP learners grow quickly!