A
A
Artyom Alexandrov2017-04-11 17:06:33
Yii
Artyom Alexandrov, 2017-04-11 17:06:33

How to set up a link pager?

LinkPager not showing.
controller:

public function actionIndex($page)
    {
        if(!isset($page)){
            $page = 1;
        }
    	$query = VpGallery::find();
    	$pages = new Pagination([
    		'totalCount' => count($query), 
    		'pageSize' => 2,
                'defaultPageSize' => 2,
    		'pageSizeParam' => false,
            'page' => $page - 1,
        ]);
    	$models = $query->orderBy('name')->offset($pages->offset)->limit($pages->limit)->all();
        return $this->render('index', ['models' => $models, 'pages' => $pages]);
    }

view:
// и так неотображается
        <?php echo LinkPager::widget([
            'pagination' => $pages,
        ]); ?>
        // и так неотображается
        <?= LinkPager::widget([
            'pagination' => $pages,
        ]); ?>

Displays as many elements on the page as specified in Pagination. Pages are displayed if you set the page number manually in the browser line.
I can't figure out what's wrong. Please help me figure it out.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Artyom Aleksandrov, 2017-04-11
@kradwhite

Damn what a tin. The question is closed.
I changed the line in the controller from:
to:
And it appeared.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question