M
M
Maxim2017-10-07 21:23:15
Yii
Maxim, 2017-10-07 21:23:15

Yii2 how to competently implement a site with several cities?

Help, please, to make the implementation of the choice of cities on the site. It is necessary to make it so that the user can select a city and only the records of the selected city are shown to him. Cities are located in the database in the table 'city' and have columns 'id', 'name', 'url'
When choosing from the drop-down list, we get the selected city and substitute it in Url. It turns out something like this

www/site.ru/moscow/post/
www/site.ru/spb/post/
www/site.ru/moscow/user/

It is also required to get the selected city and enter it into the $city variable, which we can use when fetching data from the 'post' table with the fields 'city_id' == $city

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Bay, 2017-10-08
@myks92

There was a question a week ago. google it.
+ this article to help you - https://habrahabr.ru/post/226931/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question