A
A
AlexRas2017-08-25 12:54:02
Yii
AlexRas, 2017-08-25 12:54:02

Yii2 how to write such rule for Urlmanager?

Hello, there is a rule:

'repetitory/<city>' => 'search-tutor/index',
'repetitory/<subject>' => 'search-tutor/index',

The parameter can be a city or an object, but in the end, in any case, only the first rule works.
In all cases, $_GET['city'] returns the value of city and subject, while $_GET['subject'] returns nothing.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander Aksentiev, 2017-08-25
@AlexRas

What about the meaning?
Naturally, everything will go in one, understand inside the controller what to look for there. determine on the go what has come.
How should it parse itself what kind of link it is?
After all, it even goes to one controller and method, what is the point of this action then?

M
Mikhail Serenkov, 2017-08-25
@miserenkov

'repetitory/<city>/<subject>' => 'search-tutor/index',
'repetitory/<city>' => 'search-tutor/city',

It's best to do so. Since your subject can theoretically be the same in several cities, and then it will generally be unclear from which city to pull the subject.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question