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   2575 Views

Avatar
Futureweb

26 September 2011 at 9:48am Community Member, 233 Posts

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

26 September 2011 at 12:29pm Community Member, 244 Posts

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

Avatar
Futureweb

26 September 2011 at 12:50pm Community Member, 233 Posts

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

Avatar
HARVS1789UK

22 September 2012 at 12:34am (Last edited: 22 September 2012 12:35am), Community Member, 21 Posts

Perfect, this solved the issue for me.

e.g.

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

rather than

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

Cheers,

HARVS

Avatar
nglanbt

11 February 2013 at 6:46pm Community Member, 2 Posts

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

Avatar
ajshort

11 February 2013 at 6:48pm Community Member, 244 Posts

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