yii2-reversed-pagination reversed pagination with redistribution items on page and paginator

  1. Requirements
  2. Install
  3. Usage
  4. Resources

Reversed pagination with redistribution items on page and paginator

Requirements

Yii 2.0 or above

Install

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 yourcomposer.json`

Usage

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
    ]);

Resources

0 0
1 follower
0 downloads
Yii Version: 2.0
License: BSD-2-Clause
Category: User Interface
Developed by: loveorigami
Created on: Jan 10, 2015
Last updated: 9 years ago

Related Extensions