Custom paging implementation method for Yii view Operation _php Instance

Source: Internet
Author: User
Tags smarty template yii

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.