Answer the question
In order to leave comments, you need to log in
How to set a rule to create a link in linkpager Yii2?
I generate the output using
ListView in the novosti/default/index
module view The paginator generates links like /novosti/?page=2
I would like to get a link like: /novosti/2
Widget settings (nothing special):
<?= ListView::widget([
'dataProvider' => $dataProvider,
'itemOptions' => ['class' => 'item uk-width-1-1'],
'itemView' => '_news_short',
'layout' => '{items}{pager}',
'options' => ['class' => 'uk-grid uk-clearfix'],
'pager' => [
'options'=> ['class' => 'uk-width-1-1 uk-pagination uk-text-center'],
'activePageCssClass'=>'uk-active',
],
]) ?>
'novosti'=>'novosti/default/index',
'novosti/<category:[\w_-]+>'=>'novosti/default/category',
'novosti/<category:[\w_-]+>/<id:[\w_-]+>'=>'novosti/default/view',
Answer the question
In order to leave comments, you need to log in
I decided it myself, earlier it came to mind, I just wrote the rule in the wrong place, I had to specify the rule above the first one that I indicated in the question:
//для первой страницы
['pattern'=>'novosti','route'=>'novosti/default/index','defaults'=>['page'=>1]],
//для остальных
'novosti/<page:\d+>'=>'novosti/default/index',
// а потом уже
'novosti'=>'novosti/default/index',
'novosti/<category:[\w_-]+>'=>'novosti/default/category',
'novosti/<category:[\w_-]+>/<id:[\w_-]+>'=>'novosti/default/view',
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question