Reputation: 355
I'd like to set the url rules for someting like: www.domain.com/slug in url for multiple controllers. I have one model "Content" and there is a column called content type in the "Content" model. Eg. content_type = 1 means contest, content_type = 2 means post, content_type = 3 means product etc. I have created a controller for each of the content_type, contestController, postController, productController.
I wonder if there is a way to keep the urls in the following format for few different controllers:
'<slug:.*?>'=>'contest/view', // content type contest - contestController
'<slug:.*?>'=>'post/view', // content type post - postController
'<slug:.*?>'=>'product/view', // content type product - productController
it does work with just one rule above as per yii documentation.
Upvotes: 1
Views: 187
Reputation: 1162
Not direct answer but, have you considered another approach?
Send everything to 1 controller
'<slug:.*?>'=>'post/view',
Split router by controller
'post/<slug:.*?>'=>'post/view',
Split router by type flag (not tested)
'<slug:[\w][\-\w]*?>/post'=>'post/view',
'<slug:[\w][\-\w]*?>/product'=>'product/view',
Other then that I do not see how it could work.
Upvotes: 3