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

urlParams - more info


Reply


2 Posts   1564 Views

Avatar
Ryan M.

Community Member, 309 Posts

20 December 2009 at 11:24am

I see this bit of code being used in some places: $this->urlParams['']. I've seen an ID or an Action being passed with this, and you can pass something off to this by appending it to the url, such as: http://domain.com/Page/actionname. My questions are, how deep can this go? How does it know what I'm passing is an ID or some kind of action, or something else? Does it matter if I reverse the order up, like... domain.com/Page/actionname/ID or domain.com/Page/ID/actionname

Just looking for some light to be shed on this particular thing.

Avatar
banal

Community Member, 901 Posts

20 December 2009 at 12:50pm

Edited: 20/12/2009 12:52pm

It's always Action/ID/OtherID.
This is defined as a "rewrite-rule" in sapphire/_config.php

Director::addRules(1, array(
   '$URLSegment//$Action/$ID/$OtherID' => 'ModelAsController',
));

You can create your own rules if you need other syntax or more parameters.
Update: Action usually refers to a method on the controller. Eg. somepage/test calls the "test" method on the somepage controller