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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Controller gets a page-not-found


Go to End


3 Posts   2491 Views

Avatar
eceers

Community Member, 24 Posts

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.

Avatar
eceers

Community Member, 24 Posts

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.

Avatar
martimiz

Forum Moderator, 1391 Posts

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