M
M
Monitorkin2017-03-24 09:54:48
Yii
Monitorkin, 2017-03-24 09:54:48

How to set up urlManager?

There is a table of product categories with the following fields:
cat_id: category index
cat_name: category name
parentcat_id: parent category index
alias: part of the address - transliteration of the category name (can contain both letters and numbers).
For example, it contains categories:

cat_idcat_nameparentcat_idalias
oneCatalog0catalog
2TVsonetele
3Autooneauto
4Auto BMW3bmw
5Diesel4diesel

Nesting levels 4 (this is in practice, but in theory it is infinite).
All materials of the category are displayed by the CategoryController controller, action: view($alias)
That is, if you enter the address:
  • site.ru/catalog/tele - you need to catch $alias=tele and pass it to the action
  • site.ru/catalog/avto/bmw - $alias=bmw
  • site.ru/catalog/bmw/diesel - $alias=diesel

What would the UrlManager rules look like in this case?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey, 2017-03-24
@masterfreelance

catalog/<alias> => category/view

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question