Hello!
My experience with yii has been pretty basic so far, but I’ve been using it on and off for two or three years now: and, I’m trying to learn about the urlManager next(never had to use it before ).
In the yii guide there is an example of almost exactly what I want to try doing.
They show an example where using this url:
$this->createUrl('post/read',array('id'=>100))
would generate the url "post/100" based on this rule:
'post/<id:\d+>'=>'post/read'
I tried using that format but get a blank screen with my version of the rule:
'map/<id:\d+>'=>'map/getcurrentlocation'
…And my url:
$this->createUrl('map/getcurrentlocation',array('id'=>178))
…And when my urlManager rules look like this:
'rules'=>array(
# my rules
''=>'map/index', // home page is maps list
'map/<id:\d+>'=>'map/getcurrentlocation', // the rule I'm trying to get working
# yii default rules
'<controller:\w+>/<id:\d+>'=>'<controller>/view',
'<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
),
If I change the rule I’m trying to get working to this:
'<controller:\w+>/<id:\d+>'=>'map/location'
I no longer get a blank screen initially, and the data loads as expected: but, the resulting url includes the action name like this:
map/getcurrentlocation/178
I was still expecting the url to result in this:
map/178
If someone could please point out why I get the blank screen using the original rule format(or let me know that it could be a number of things): and, why using my updated rule format results in having the action name in the generated url, that would be fantastic!