This example describes a custom paging implementation for the Yii view operation. Share to everyone for your reference, specific as follows:
1. View file call Cgridview,clistview 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: {pages}/{page} page ', ' Columns ' =>array (Array (' class ' => ' Ccheckboxcolumn ', ' F Ooter ' => ' <button onclink= "DeleteAll ()" >button</button> <button onclink= "Refashall ()" >button& Lt;/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 ( $data->content), 0,10, "utf-8") ', ', Array (' Name ' => ' type ', ' Value ' => "News::model ()->getnewstype ($data-& Gt;type) ', ', ' user ', Array (' NAMe ' => ' status ', ' Value ' => ' News::model ()->getnewsstatus ($data->status) ',), Array (' class ' => ' CBu Ttoncolumn ', ' Buttons ' =>array (' View ' =>array (' Visible ' => ' false '),//' delete ' =>array (' click ' => ' tr
UE '),),);
2. Copy the base class paging class file, make changes to become your own paging method
framework/web/widgets/pagers/clistpager.php copy and life name to protected/components/zpager.php Modify class name
FRAMEWORK/WEB/WIDGETS/PAGERS/PAGER.CSS copy the corresponding style file to Protected/components/css/pager.css
Modify the zpager.php CSS loading directory
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 CSS style files, you can also modify the program that generates the list to achieve the purpose of modifying the classification.
For more information on YII-related content, readers who are interested in this site can view the topics: Introduction to YII Framework and summary of common skills, "Summary of PHP Excellent development framework", "Smarty Template Introductory Course", "Introduction to PHP object-oriented programming", "PHP string" Summary of Usage , "Php+mysql Database operation Introduction Tutorial" and "PHP common database Operation Skills Summary"
I hope this article will help you with the PHP program design based on the YII framework.