sjaakp/yii2-datepager
Composer 安装命令:
composer require sjaakp/yii2-datepager
包简介
Page data on date value in Yii2.
README 文档
README
Paging on date values for Yii2
These classes enable database paging based on date values in the Yii 2.0 PHP Framework.
A demonstration of yii2-datepager is here.
Installation
The preferred way to install yii2-datepager is through Composer.
Either add the following to the require section of your composer.json file:
"sjaakp/yii2-datepager": "*"
Or run:
composer require sjaakp/yii2-datepager "*"
You can manually install yii2-datepager by downloading the source in ZIP-format.
Using Datepager
Using Yii2 Datepager is easy. A minimum usage scenario would look like
the following. In EventController.php we would have something like:
<?php
use sjaakp\datepager\ActiveDataProvider;
class EventController extends Controller
{
// ...
public function actionIndex() {
$dataProvider = new ActiveDataProvider([
'query' => Event::find(),
'dateAttribute' => 'date'
]);
return $this->render('index', [
'dataProvider' => $dataProvider
]);
}
// ... more actions ...
}
The corresponding view file index.php could look something like:
<?php
use sjaakp\datepager\DatePager;
?>
<?= DatePager::widget([
'dataProvider' => $dataProvider
]) ?>
<?= GridView::widget([
'dataProvider' => $dataProvider,
'columns' => [
'date',
'title',
// ... more columns ...
],
]); ?>
Classes
ActiveDataProvider
This is an extension from its Yii-counterpart in yii\data, and can be used in
the same way. It is important to set attribute $dateAttribute.
$dateAttribute
string Set this to the name of the attribute which is used to define the pages.
Must be set.
$interval
string Defines the interval of the pages. Must be set in a form PHP's
DateInterval
can understand. Default: 'P1Y' (one year).
$ascending
bool Whether the DatePager pages are rendered in ascending or descending
order. Default: true (ascending).
$beginDate
string Date of the first Datepager page. If not set (default), Datepager determines
this date itself. It can be set to any date within the range of the first page.
Format: any PHP date format.
$endDate
string Date of the last Datepager page. If not set (default), Datepager determines
this date itself. It can be set to any date within the range of the last page.
Format: any PHP date format.
$dateParam
string The Datepager HTML parameter name. Default value: 'date'. Might be changed
if there is a conflict with other functionality.
DatePager
This is the widget that renders the actual datepager.
The attribute $dataProvider must be set.
$dataProvider
The Datepager ActiveDataProvider that this pager is associated with.
Must be set.
$maxButtonCount
int The maximum number of page buttons rendered. Default: 10.
$labelFormat
null|string|callable Defines the format of the page label.
- If
null: DatePager determines the format based on the dataprovider's interval. - If
string: a date format according to Yii'sFomrmatter::dateformat. - If
callable: afunction($page, $datePager), returning astring, where$pageis a PHPDateTimeInterface.
$options
array HTML options for the datepager container tag.
Default: [ 'class' => 'pagination' ], compatible with Bootstrap.
$buttonOptions
array HTML options for the datepager buttons.
Default: [ 'class' => 'page-item' ], compatible with Bootstrap 4.
$linkOptions
array HTML options for the datepager links.
Default: [ 'class' => 'page-link' ], compatible with Bootstrap 4.
$activePageCssClass
string CSS class of the active page. Default: 'active'.
$disabledPageCssClass
string CSS class of a disabled page. Default: 'disabled'.
$prevPageLabel, $nextPageLabel
'string' Text labels for the previous and next buttons, will not be HTML encoded.
If false, the button will not be rendered. Defaults: '«' and '»'.
$firstPageLabel, $lastPageLabel
'string' Text labels for the first and last buttons, will not be HTML encoded.
If false (default), the button will not be rendered.
All properties, except $dataProvider and $labelFormat are direct equivalents of
their counterparts in Yii's LinkPager.
sjaakp/yii2-datepager 适用场景与选型建议
sjaakp/yii2-datepager 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 171 次下载、GitHub Stars 达 1, 最近一次更新时间为 2020 年 02 月 04 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「paging」 「pagination」 「extension」 「yii」 「widget」 「yii2」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 sjaakp/yii2-datepager 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 sjaakp/yii2-datepager 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 sjaakp/yii2-datepager 相关的其它包
同方向 / 同关键字的高下载量 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
统计信息
- 总下载量: 171
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 7
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-02-04