21307 Posts in 5737 Topics by 2603 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1249 Views |
-
Controller gets a page-not-found

2 June 2010 at 8:08pm
Hi All,
I have this Controller;
class VideoDisplay_Controller extends Controller
{
static $allowed_actions = array(
'action' => true
);
function action($arguments) {
return 'Something';
}
}Which I'm setting up with;
Director::addRules(20, array('video-display/$Action/$Type/$Id/' => 'VideoDisplay_Controller'));
When I try accessing the controller through http://localhost/video-display/action I get a page-not-found.
I'm using 2.4
The only mention of this type of behaviour I found on this page http://www.balbus.tk/simulating-page-urls/ but he doesn't mention how to fix it.
Any help would be greatly appreciated.
-
Re: Controller gets a page-not-found

3 June 2010 at 2:09pm
Not sure if this is the problem or if there is another reason. It appears that Silverstripe is not seeing the Controller file at all. I have created an obvious parse error and it does not catch it on the server.
I have delved into the documentation and everything I have found says that I'm doing the right thing but alas it no workie
I really need some help with this if anyone can help please.
-
Re: Controller gets a page-not-found

19 July 2010 at 12:14am
Just in case you're still looking for a solution: you did everything about right. It should work and it probably will once you remove the trailing slash after $Id from the Director rule like so:
Director::addRules(20, array('video-display/$Action/$Type/$Id/' => 'VideoDisplay_Controller'));
replace by
Director::addRules(20, array('video-display/$Action/$Type/$Id' => 'VideoDisplay_Controller'));
The problem: for some reason, if you add the trailing slash, SilverStripe will treat it as if another empty(!) parameter is added to the rule, and will try to match it (in HTTPRequest::match()), and fail. I don't know if this is 'by design', but if not, it would be nice to filter it out, since this is a typo easily made.
Cheers, Martine
| 1249 Views | ||
|
Page:
1
|
Go to Top |

