Table of Contents
yii2分页扩展之实现跳转到具体某页,yii2分页扩展跳转
Home php教程 php手册 yii2分页扩展之实现跳转到具体某页,yii2分页扩展跳转

yii2分页扩展之实现跳转到具体某页,yii2分页扩展跳转

Jun 13, 2016 am 08:38 AM

yii2分页扩展之实现跳转到具体某页,yii2分页扩展跳转

作者:白狼 出处:http://www.manks.top/yii2_linkpager_widget.html 本文版权归作者,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。

先上图看效果,样式虽然有点丑,这都不重要,我相信拿到代码的你们更注重的是这功能怎么实现的!

(图片见原文)

从上图中不难看出,我们制定跳转到某页的功能是基于linkpager之上的扩展,这根我们之前实现的分页扩展明显不同,之前的明显就是重写了!当然,这都不重要,我们看看GoLinkPager的具体实现!名字起的有点lower,不重要!
1、在frontend\components目录新建GoLinkPager类文件

2、该类继承yii\widgets\LinkPager;,如下:

<span>namespace frontend\components; 
</span><span>use</span><span> yii\widgets\LinkPager; 
</span><span>use</span><span> yii\helpers\Html; 
</span><span>class</span> GoLinkPager <span>extends</span><span> LinkPager 
{ 
}</span>
Copy after login

 

3、添加属性public $go = false; //是否包含跳转功能跳转 默认false

4、重写父类linkPager的renderPageButtons方法,具体直接参考下面完整版代码,可主要看go部分的代码实现。

[考虑目前国内网站大部分采集文章十分频繁,更有甚者不注明原文出处,原作者更希望看客们查看原文,以防有任何问题不能更新所有文章,避免误导!]

继续阅读

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

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
Two Point Museum: All Exhibits And Where To Find Them
1 months ago By 尊渡假赌尊渡假赌尊渡假赌

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)