Home php教程 PHP开发 Yii view operation custom paging implementation method

Yii view operation custom paging implementation method

Dec 30, 2016 pm 04:11 PM

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(&#39;zii.widgets.grid.CGridView&#39;, array(
 &#39;id&#39;=>&#39;news-grid&#39;,
 &#39;dataProvider&#39;=>$model->search(),
 &#39;filter&#39;=>$model,
 &#39;template&#39;=>&#39;{items}{summary}{pager}&#39;,
  &#39;selectableRows&#39;=>2,
  &#39;pager&#39;=>&#39;ZPager&#39;,
  &#39;summaryText&#39;=>&#39;页数:{pages}/{page}页&#39;,
  &#39;columns&#39;=>array(
  array(
   &#39;class&#39;=>&#39;CCheckBoxColumn&#39;,
   &#39;footer&#39;=>&#39;<button onclink="deleteAll()">button</button>
      <button onclink="refashAll()">button</button>&#39;,
   &#39;footerHtmlOptions&#39;=>array(&#39;colspan&#39;=>5),
   &#39;selectableRows&#39;=>2,
  ),
  &#39;id&#39;,
  array(&#39;name&#39;=>&#39;title&#39;,
    &#39;htmlOptions&#39;=>array(&#39;width&#39;=>&#39;20%&#39;),
    &#39;value&#39;=>&#39;mb_substr($data->title,0,10,"utf-8")&#39;,
   ),
  array(&#39;name&#39;=>&#39;content&#39;,
    &#39;htmlOptions&#39;=>array(&#39;width&#39;=>&#39;20%&#39;),
    &#39;value&#39;=>&#39;mb_substr(strip_tags($data->content),0,10,"utf-8")&#39;,
   ),
  array(&#39;name&#39;=>&#39;type&#39;,
    &#39;value&#39;=>&#39;News::model()->getNewsType($data->type)&#39;,
   ),
  &#39;user&#39;,
  array(&#39;name&#39;=>&#39;status&#39;,
    &#39;value&#39;=>&#39;News::model()->getNewsStatus($data->status)&#39;,
    ),
  array(
   &#39;class&#39;=>&#39;CButtonColumn&#39;,
   &#39;buttons&#39;=>array(
    &#39;view&#39;=>array(&#39;visible&#39;=>&#39;false&#39;),
    //&#39;delete&#39;=>array(&#39;click&#39;=>&#39;true&#39;),
   ),
  ),
 ),
));
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(&#39;application.components.css.pager&#39;).&#39;.css&#39;);
 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!

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)