Hi all,
I need to create URLs like this one:
http://mysite.com/theuser/photos/view/84297512930/
where theuser can be any of the users of the website, photos is a controller, view the action and the number is the id of the image?
The same for /theuser/photos/add, /theuser/video/1929391 etc…
How can I accomplish this?
Best regards,
Luis
jacmoe
(Jacob Moena)
November 1, 2010, 4:06am
2
I am just a beginning Yii-user, so bear with me…
Take a look at this:
http://www.yiiframework.com/forum/index.php?/topic/12743-prefix-routing/
You could probably do something like this:
'<username>/<controller:\w+>/<action:\w+>/<id:\d+>' => '<controller>/<action>',
'<username>/<controller:\w+>/<action:\w+>' => '<controller>/<action>',
That means that ‘username’ must be passed around.
But take a look at the link and study the URL manager.
ignis55
(I Nedzinskas)
November 1, 2010, 6:44am
3
you can easy do this by setting all path to your folder. Take a look to this function getBaseUrl . setting first argument to true you will be able to get all path and then just specify your folder location manually
jacmoe:
I am just a beginning Yii-user, so bear with me…
Take a look at this:
http://www.yiiframew …prefix-routing/
You could probably do something like this:
'<username>/<controller:\w+>/<action:\w+>/<id:\d+>' => '<controller>/<action>',
'<username>/<controller:\w+>/<action:\w+>' => '<controller>/<action>',
That means that ‘username’ must be passed around.
But take a look at the link and study the URL manager.
Thank you! That was the solution
I used
‘<userName:\w+>/<_c:(photo)>/<_a:\w+>/<idPhoto:\d+>’ => ‘<_c>/<_a>’,
this way I can use URLs like /luislobo/photo/edit/10 or /luislobo/photo/view/10