Answer the question
In order to leave comments, you need to log in
Yii2 why pagination numbering is 1 page behind?
Implemented pagination like this:
public function actionArticles($page = 1)
{
$query = Blog::getArticles();
$countQuery = clone $query;
$pages = new Pagination(['totalCount' => $countQuery->count()]);
$pages->page = $page;
$models = $query->offset($pages->offset)
->limit($pages->limit)
->all();
return $this->render('articles', [
'articles' => $models,
'pages' => $pages,
]);
}
Answer the question
In order to leave comments, you need to log in
https://github.com/yiisoft/yii2/blob/master/framew... here, as if directly written, the numbering starts from 0
and here is how everything works inside https://github.com/yiisoft/yii2/blob/master /framew...
or you can remove the parameter from actionArticles, Pagination will pick it up by itself. Parameter name can be customized https://github.com/yiisoft/yii2/blob/master/framew...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question