Greetings, I want to make the number of articles on one page - dynamic (so that the user chooses), but I can’t figure out exactly how to do it. I am writing on the basic template. Here is the paginator code in the controller:
if($AllPosts) { $pages = new Pagination(['totalCount' => $AllPosts->count(), 'pageSize' => $postPerPage]); $posts = $AllPosts->offset($pages->offset) ->limit($pages->limit) ->all(); return $this->render('index', [ 'posts' => $posts, 'pages' => $pages, ]); } Here is the call from the view:
<?= \yii\widgets\LinkPager::widget([ 'pagination' => $pages ]); ?>