S
S
Svyatoslav Torg2016-06-20 09:08:32
Yii
Svyatoslav Torg, 2016-06-20 09:08:32

Dynamic URL how to do?

Yii2 - Advanced template
Hello, imagine a car catalog:
on index you see a list of Brands, for example, go to url: mysite.ru/lada - dynamically changes from the brand name, I did this in 'urlManager' => 'rules' => [' < name: \w+ > ' => 'catalog/mark'] works great.
And then I choose a model of this brand, and I want to see in the url, for example,
mysite.ru/lada/priora, but I understand that I don’t understand how to describe the rule,
so far I have this, 'model/ < name: \w+ >' => 'catalog/model',
and the output is actually
mysite.ru/model/priora ))
In general, here, but it should be as written above.
I pass the name of the brand to GET and use it to make a selection.
I understand that I can keep a field with the name of the brand in the database in the records of the model table and send it as the second parameter to get and create the Url I need, but this is nonsense.
Who can advise?)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
vyachin, 2016-06-20
@sefkiss

you can and how you want, there is even an example in the documentation https://github.com/yiisoft/yii2/blob/master/docs/g...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question