A few questions from a complete noobie to YII and only marginally familiar with MVC architecture... I've gone through the screencasts and looking for more examples/tutorials.
Unfortunately, there are a few things I can't figure out...
History: I'm moving a perl/mysql system using a custom data-store to a more standard relational model with a YII front-end.
The original developer put in some interesting logic when viewing a text area that I now either have to convert or mimic in the new system... Examples.
- Putting in the text <table_x:meta_name> will create a link to the webroot/table_x/view/ for that record or list of records.
- Putting the same into double brackets <<table_x:meta_name>> links to an attached file and will download it.
- Putting in triple brackets <<< >>> will link to the record and attempt to display the attached file in-line.
I can't seem to get a handle on the urlmanager module and need to make the links work. As an example, here's what I need (I can't include the full url since I'm new)
/ncs/index.php/table_x/meta_name/xxx-xxxx-00/meta_version/2
would link to the table_x table and show a single record with meta_name = xxx-xxxx-00 and meta_version = 2
/ncs/index.php/table_x/meta_name/xxx-xxxx-00
would link to the table_x table and get a list of all versions of the record with meta_name xxx-xxxx-00
Any help would be much appreciated
Many thanks,
Dennis
Page 1 of 1
Help With Urlmanager
#2
Posted 11 September 2012 - 02:22 PM
If you can build regexp for your urls then you can easily map urls to controllers and actions.
Docs:
http://www.yiiframew...amed-parameters
Docs:
http://www.yiiframew...amed-parameters
Born to create drama
#3
Posted 12 September 2012 - 12:11 PM
ORey, on 11 September 2012 - 02:22 PM, said:
If you can build regexp for your urls then you can easily map urls to controllers and actions.
Docs:
http://www.yiiframew...amed-parameters
Docs:
http://www.yiiframew...amed-parameters
I had tried that with very limited success.
- If I want to view a single record using the standard main.php that gii creates, I can do localhost:8888/ncs/index.php/fmo/view/id/2 and it works fine but isn't what I'm after.
- If I change the ID rule to '<controller:\w+>/<id:\d+>'=>'<controller>/admin' and use the url localhost:8888/ncs/index.php/fmo/admin/id/2, it shows all records in the admin screen rather than just that of ID=2
- If I add to the top of the rules "'<controller:\w+>/<meta_name:\w+>'=>'<controller>/view'," and use localhost:8888/ncs/index.php/fmo/view/meta_name/test-01-01, it comes back with an error 400.
URL manager call looks like the following (although I'd like the top 2 conditions to show in the admin screen instead of view:
'urlManager'=>array(
'urlFormat'=>'path',
'caseSensitive'=>'false',
'rules'=>array(
'<controller:\w+>/<meta_name:\w+>'=>'<controller>/view',
'<controller:\w+>/<id:\d+>'=>'<controller>/view',
'<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
),
),
Share this topic:
Page 1 of 1

Help













