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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

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

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

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


Go to End


6 Posts   5519 Views

Avatar
JonShutt

Community Member, 244 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
JonShutt

Community Member, 244 Posts

26 September 2011 at 12:50pm

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

Avatar
HARVS1789UK

Community Member, 31 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');