2

I have the following rule, in my config/main.php:

'<controller:\w+>/<action:\w+>/<param:\w+>'=>'<controller>/<action>',

Can I have in ExperienceController an action actionListByDistrict($param) that is called when the URL /mysite/experience/district/value is used?

I would like to do a kind of mapping in Yii Framework, but how? Actually the action takes this form: actionDistrict($param).

2 Answers 2

1

The rule that I mention on the comment should work:

'experience/district/<param:\w+>'=>'experience/listByDistrict'

Make sure this specific rule stays on top, because the order on Yii UrlManager Rules matters.

About the general rule however, I don't see way for doing it atm.

:)

Sign up to request clarification or add additional context in comments.

Comments

0

You can try that 'experience/district/<id:\d+>'=>'experience/listByDistrict/',

2 Comments

id expects a number (d+) and the param is a word. So changing to w+ and use param instead of id may work instead? Still, the OP may wish to a have a general regex rule, so that it doesn't end with 10 lines of code, when one would be enough.
'experience/district/<param:\w+>'=>'experience/listByDistrict/', still doesn't solve. The system looks for an action called district. And as @MEM said, it would be interesting if there was a general rule for it, considering the last word of listByDistrict.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.