Ho can I set up urlManager patterns in a way that it works like twitter or any other social networks? for example I want to have the following routes:
http://www.example.com/[user_id]
http://www.example.com/[user_id]/[mycontroller]/[myaction]
- If users write their user_id it goes to their dahboard page.
- If user write their user_id followed by a controller and action name it proceeds to proper controller action
Add the following two URLs.
The first rule will match any digit and execute the index action of the profile controller. The index action will receive the user ID, so the function will, most likely, look like
public function actionIndex($user_id)So
/1would executeactionIndexof theProfileControllerand passing 1 as the$user_id.The second rule will match any digit followed by two words, separated by a slash of course.
So
/1/some/somethingwould executeactionSomethingin theSomeController. And theactionSomethingwould again receive the$user_id.