5102 Posts in 1520 Topics by 1116 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 2244 Views |
-
Default $Controller//$Action routing question

4 December 2009 at 5:33am
I apologize if this is a stupid question. I was unable to find anything else about this on the forums. The documentation says in several places that there should be a default routing rule to map "/team/signup" to "Team_Controller::signup()", provided that controller exists. It sounds to me like you don't need to set up a Director rule to facilitate such a mapping, and when I look at the rules via ?debug=1, I see a rule on there that SHOULD map that way as far as I can tell, but I haven't been able to get it to work. Can someone confirm that the documentation is correct? I'm looking at:
http://doc.silverstripe.org/doku.php?id=recipes:controllers (under Simulate Pages with Controllers)
And also:
http://doc.silverstripe.org/doku.php?id=execution-pipeline (under Controllers and actions)
Thanks.
Mark -
Re: Default $Controller//$Action routing question

4 December 2009 at 9:30am
As long as you have a Page in the CMS with the classname 'TeamPage' and the URLSegment 'team' then yes that it automatic. Basically the /team/ action looks for the controller on a page with the URL 'team'. If you don't have a page which provides this mapping then you'll have to use the Classname as the URL like '/Team_Controller/signup/' if you want the /team/ url and don't have a page mapping then you'll have to write a custom routing action like this in your _config
Director::addRules(100, array(
'team/$Action/$ID' => "Team_Controller",
)); -
Re: Default $Controller//$Action routing question

17 December 2009 at 1:39pm
Thanks for the reply. You're correct that /Team_Controller/ seems to work. I would suggest the documentation be updated in the following ways:
1. On this page: http://doc.silverstripe.org/doku.php?id=execution-pipeline
Change: "You can access the following controller-method with /team/signup"
To: "You can access the following controller-method with /Team_Controller/signup"2. On this page: http://doc.silverstripe.org/doku.php?id=recipes:controllers
The information all appears to be correct, but I would add some clarification on this line: "More native URL-Layout (â€/team/create†instead of “/myteampage/createâ€)" - something along the lines of "More native URL-Layout (â€/team/create†instead of “/myteampage/create†- Please note the default routing would be /Team_Controller/create unless you set up custom routing)".
3. There was one other place where the documentation was explicitly wrong, but I can't find it. It was actually even worse because it had controller action methods declared as "function myaction($param1, $param2){}" which, as I understand is also wrong.
Thanks,
Mark
| 2244 Views | ||
|
Page:
1
|
Go to Top |

