loveorigami / yii2-reversed-pagination
Yii2 reversed pagination
Installs: 657
Dependents: 0
Suggesters: 0
Security: 0
Stars: 10
Watchers: 7
Forks: 2
Open Issues: 0
Type:yii2-extension
Requires
- yiisoft/yii2: ~2
This package is auto-updated.
Last update: 2024-10-21 21:06:02 UTC
README
Installation
Composer
The preferred way to install this extension is through Composer.
Either run php composer.phar require loveorigami/yii2-reversed-pagination "~2.0"
or add "loveorigami/yii2-reversed-pagination": "~2.0"
to the require section of your composer.json
Using
Use for reversed pagination for Yii2.
In controller
public function actionIndex() { $query = Article::find()->all(); $countQuery = clone $query; $pages = new \loveorigami\pagination\ReversePagination( [ 'totalCount' => $countQuery->count(), 'pageSize' => 10, // or in config Yii::$app->params['pageSize'] ] ); $pages->pageSizeParam = false; $models = $query->offset($pages->offset) ->limit($pages->limit) ->all(); return $this->render('index', [ 'models' => $models, 'pages' => $pages, ] ); }
In view
foreach($models as $model): // display a model... endforeach; echo \loveorigami\pagination\ReverseLinkPager::widget([ 'pagination' => $pages, 'registerLinkTags' => true ]);