A
A
akula222015-12-15 11:56:24
Yii
akula22, 2015-12-15 11:56:24

How to correctly specify links in yii2?

In the news module, I display a link to the news in this way

<?= Html::a($model->title, ['view', 'slug' => $model->slug, 'id' => $model->id]) ?>

in urlManager the rule is:
'post/<slug:[\w_-]+>/<id:\d+>' => '/post/default/view',

As a result, I get a link: domen.ru/post/nazvanie/28
everything seems to be correct.
And on the main page I display the first 2 news, and there I also need to make links to "more"
I make the link in the same way, but I already get domen.ru/site/default/view?slug=nazvanie&id=28
How to draw a link in the second case?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Evgeny Bukharev, 2015-12-15
@akula22

<?= Html::a($model->title, ['/post/default/view', 'slug' => $model->slug, 'id' => $model->id]) ?>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question