Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Director::URLParam() seems to give me wrong values...


Reply


6 Posts   2766 Views

Avatar
Futureweb

Community Member, 233 Posts

26 September 2011 at 9:48am

Hello,

my url is mysite.com/category/subpage/shownote/1

Director::URLParam('Action') is giving me the value 'subpage' and
Director::URLParam('ID') is giving me the value 'shownote'

I'm expecting action to equal shownote, and ID to equal 1.

what am I doing wrong here?

Thanks!

Avatar
ajshort

Community Member, 244 Posts

26 September 2011 at 12:29pm

Director::urlParam() is deprecated and doesn't work properly any more - instead you should use $this->request->param() inside your controller.

Avatar
Futureweb

Community Member, 233 Posts

26 September 2011 at 12:50pm

Hi ajshort - thanks for that. now works perfectly...

Avatar
HARVS1789UK

Community Member, 21 Posts

22 September 2012 at 12:34am

Edited: 22/09/2012 12:35am

Perfect, this solved the issue for me.

e.g.

$id = $this->request->param('ID');

rather than

$id = Director::URLParam('ID');

Cheers,

HARVS

Avatar
nglanbt

Community Member, 2 Posts

11 February 2013 at 6:46pm

In case, I want to get ID param not inside of a controller. How can I do it without Director::urlParam('ID')?

Avatar
ajshort

Community Member, 244 Posts

11 February 2013 at 6:48pm

Controller::curr()->getRequest()->param('ID');