sjaakp/yii2-alphapager
Composer 安装命令:
composer require sjaakp/yii2-alphapager
包简介
Page data on initial character in Yii2.
README 文档
README
Yii2 Alphapager performs alphabetic paging with for instance GridViews or ListViews.
Just use sjaakp\alphapager\ActiveDataProvider in stead of your normal yii\dataActiveDataProvider, and put an AlphaPager widget in front of your GridView, and you're running.
Likewise with sjaakp\alphapager\ArrayDataProvider.
Alpha paging is compatible with normal pagination. You can use them together.
A demonstration of Yii2 Aphapager is here.
Important notice
Yii2 Alphapager's ActiveDataProvider is only proven to work with MySQL and MariaDB databases. It should also work with SQLite and Cubrid, but this is not tested.
In contrast to the Yii philosophy, Yii2 Alphapager is not transparent to the database, as I'm sorry to say. Presumably, ActiveDataProvider can be made to work with Oracle, Postgres, and MSSQL as well. See the comments near $regex in ActiveDataProvider.php for details. If you can provide more information on using Yii2 Alphapager with other databases, I'd be glad to hear it.
Installation
The preferred way to install Yii2 Alphapager is through Composer. Either add the following to the require section of your composer.json file:
"sjaakp/yii2-alphapager": "*"
Or run:
composer require sjaakp/yii2-alphapager "*"
You can manually install Yii2 Alphapager by downloading the source in ZIP-format.
Usage
Using Yii2 Alphapager is easy. A minimum usage scenario would look like the following. In PersonController.php we would have something like:
<?php
use sjaakp\alphapager\ActiveDataProvider;
class PersonController extends Controller
{
// ...
public function actionIndex() {
$dataProvider = new ActiveDataProvider([
'query' => Person::find()->orderBy('last_name, first_name'),
'alphaAttribute' => 'last_name'
]);
return $this->render('index', [
'dataProvider' => $dataProvider
]);
}
// ... more actions ...
}
The corresponding view file index.php could look something like:
<?php
use sjaakp\alphapager\AlphaPager;
?>
<?= AlphaPager::widget([
'dataProvider' => $dataProvider
]) ?>
<?= GridView::widget([
'dataProvider' => $dataProvider,
'columns' => [
'last_name',
'first_name',
],
]); ?>
Classes
ActiveDataProvider and ActiveArrayProvider
These are extensions from their Yii-counterparts in yii\data, and can be used in the same way. It is important to set attribute $alphaAttribute.
$alphaAttribute
Set this to the name of the attribute which is used to define the pages. Must be set.
$alphaDigits
Setting for the way attribute values starting with a digit are handled. Can have the following values:
false: no special handling; digits are treated just like any other non-alphabetic symbol (default)'full': separate pages for each digit'compact': one page for all digitsarrayof characters: alpha pager doesn't display alphabetic characters, but uses the characters in this array; useful for non-western alphabets
$alphaPages
Settings to modify alpha pagers operation. For normal use, this can remain the default value of [] (empty array). For more information, see the _AlphaTrait.php source.
$alphaDefault
Default page value; this page opens when no explicit page is given. Default value: 'A'.
$alphaParam
The alphapager HTML parameter name. Default value: 'alpha'. Might be changed if there is a conflict with other functionality.
AlphaPager
This is the widget that renders the actual alphapager. The attribute $dataProvider must be set.
$dataProvider
The Yii2 Alphapager ActiveDataProvider or ArrayDataProvider that this pager is associated with. Must be set.
$preButtons
array Page values of buttons which should appear left of the alphabetical buttons. Set this to [] if you don't want an 'all' button. Default: [ 'all' ].
$postButtons
array Page values of buttons which should appear right of the alphabetical buttons. Set this to [] if you don't want an '#' (non-alphabetic) button. Default: [ 'symbol' ].
$lowerCase
boolean Whether the alphabetic buttons are rendered in lower case. Default: false.
$options
array HTML options for the alphapager container tag. Default: [ 'class' => 'pagination' ], compatible with Bootstrap.
$buttonOptions
array HTML options for the alphapager buttons. Default: [ 'class' => 'page-item' ], compatible with Bootstrap 4.
$linkOptions
array HTML options for the alphapager links. Default: [ 'class' => 'page-link' ], compatible with Bootstrap 4.
sjaakp/yii2-alphapager 适用场景与选型建议
sjaakp/yii2-alphapager 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 4.44k 次下载、GitHub Stars 达 18, 最近一次更新时间为 2015 年 06 月 13 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「paging」 「pagination」 「extension」 「yii」 「widget」 「yii2」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 sjaakp/yii2-alphapager 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 sjaakp/yii2-alphapager 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 sjaakp/yii2-alphapager 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A custom URL rule class for Yii 2 which allows to create translated URL rules
The Yii2 extension uses jQuery jquery.carousel-1.1.min.js and makes image carousel from php array of structure defined.
TYPO3 CMS extension to create gallery content element with preset crop ratios and pagination
UI Kit 3 Extension for Yii2
Adds more BBCode
Symfony pagination bundle with support for arrays, Doctrine ORM repositories, queries, Twig rendering, and filter building
统计信息
- 总下载量: 4.44k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 19
- 点击次数: 11
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-06-13