abuduba
abuduba

Reputation: 5042

Yii url manager rules - hint needed

Assume, we've website which can be displayed in several languages. Name for each controller is rewrite to certain language. For example:

'kontakt<a:.*>' => 'contact<a>',
'uslugi<a:.*>' => 'services<a>
'<controller:\w+>/\w+,<id_body:\d+>' =>'<controller>/showBody/id/<id_body>' 

Url /kontakt redirect to /contact 'uslugi' to 'services' etc.

Ok, but I'd like to perform that result of parse also through the last controller so as to kontakt/some_irrelevant_title,5 was directed to contact/some_irrelevant_title,5

It is possible in some magic way to achieve that behavior?

Upvotes: 2

Views: 889

Answers (1)

Nate Barr
Nate Barr

Reputation: 4660

The CUrlManager module accepts regular expressions for the parameters. So use rules like these and just ignore the rule controller variable (c) in the path:

'<c:(kontakt|contact)>/<a:\w+>' => 'contact/<a>',
'<c:(uslugi|services)>/<a:\w+>' => 'services/<a>',

Upvotes: 1

Related Questions