meklop
(Alejandrofonseca)
June 16, 2012, 3:05am
1
Hi All,
I’d like to know if there is an Yii function to get a value from url. The url that I have is:
http://www.domain.com/index.php/module/controller/update/id/111
I need to get the value ‘111’ before it gets to the update action, is there an Yii method to do it? I’ve tried with:
Yii::app()->request->getUrl();
Yii::app()->request->getParams('id');
$_GET['id'];
… without success.
I’d really appreciate your help.
Thanks,
Alejandro.
rookie84
(Lifeline Is)
June 16, 2012, 3:20am
2
$id = Yii::app()->request->getQuery(‘id’); //that should do it if you are doing it all right.
Hi All,
I’d like to know if there is an Yii function to get a value from url. The url that I have is:
http://www.domain.com/index.php/module/controller/update/id/111
I need to get the value ‘111’ before it gets to the update action, is there an Yii method to do it? I’ve tried with:
Yii::app()->request->getUrl();
Yii::app()->request->getParams('id');
$_GET['id'];
… without success.
I’d really appreciate your help.
Thanks,
Alejandro.
meklop
(Alejandrofonseca)
June 16, 2012, 3:30am
3
That’s what I was looking for. Thanks very much!!
Actually, the problem was that I’d written the code in the wrong method. I was using init() function of my_moduleModule class, then changed that for beforeControllerAction function and it all worked, even
Yii::app()->getRequest()->getParam('id')
Cheers!
Alejandro.
jacmoe
(Jacob Moena)
June 16, 2012, 7:39am
4
[color="#006400 "]/* Moved from Yii Powered to Yii 1.1 General Discussion */ [/color]