Jump to:

23486 Posts in 18995 Topics by 2878 members

General Questions

SilverStripe Forums » General Questions » urlParams - more info

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

Page: 1
Go to End
Author Topic: 1533 Views
  • Ryan M.
    Avatar
    Community Member
    309 Posts

    urlParams - more info Link to this post

    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.

  • banal
    Avatar
    Community Member
    901 Posts

    Re: urlParams - more info Link to this post

    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

    1533 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.