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

How to get the url parameter


7 Posts   3969 Views


16 March 2010 at 8:47pm Community Member, 10 Posts

Hi! This might seem a little dumb question but I would just like to know how to get the URL Parameter of a certain site.
For example, I have this url:

What i want is to get the forum AND the thread-one parameter.

Any ideas?

Thanks! :)


16 March 2010 at 9:50pm (Last edited: 16 March 2010 9:51pm), Community Member, 901 Posts


The first part of the URL (forum) is the URLSegment (you can get it using $this->URLSegment). The second part (thread-one) is the action. To access it use:

$action = Director::urlParam('Action');


16 March 2010 at 9:55pm (Last edited: 16 March 2010 9:56pm), Community Member, 10 Posts

hi! I tried it and I dump it to see if it shows a value but unfortunately, I get a NULL value :'(


result is NULL


16 March 2010 at 10:22pm Community Member, 901 Posts

Where in your code is that dump statement?


16 March 2010 at 10:46pm (Last edited: 16 March 2010 10:47pm), Community Member, 10 Posts

In my widget controller. In this method:

function UserReviewsCommentFormStepOne() {
   $URLParams = Director::urlParam('Action');
      //$Segment = $URLParams['Action'];
      //$a = new HTTPRequest();
$fields = new FieldSet(
new TextareaField("Pros","What did you like about this room?"),
new TextareaField("Cons","What did you not like in this room?"),
new OptionsetField("RecommendRoom",'Do you recommend this room?',array(
$actions = new FieldSet(new FormAction('doUserReviewsCommentFormStepOne', 'next'));
$validator=new RequiredFields('Pros','Cons');
$form = new Form($this, 'doUserReviewsCommentFormStepOne', $fields, $actions);

return $form;

Also, I added a rule in my_config file for the thing that you said occur.
Something like this:

Director::addRules( 100, array(
   'reviews/$Action' => 'UserReviewsWidget_Controller'


17 March 2010 at 12:15am Community Member, 901 Posts

Hmm I never heard of a Widget Controller. I always thought Widgets don't have a controller themselves.
Accessing the Action is certainly possible in a Page-Controller, can't help you with widgets though. Sorry.
Maybe somebody else can give some pointers?


17 March 2010 at 3:58am Community Member, 10 Posts

no no...I'm wrong. it's page controller actually