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're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

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

Problem with Controller not found


Go to End


3 Posts   1651 Views

Avatar
ImacSS

Community Member, 35 Posts

19 October 2010 at 8:35am

Trying to make a Controller to handle custom exporting of data.
Created a file CompetitionExport_Controller.php and placed into code directory.

class CompetitionExport_Controller extends Controller
{
	function index() {
		return $this->renderWith('CompetitionReport_Export');
	}
}

In the config file, I have defined this rule:

Director::addRules(50, array(
	'compexp/$Action/$ID' => 'CompetitionExport_Controller'
));

Yet when I go to the URL http://mysite/compexp/index/621 I receive the following error:
Fatal error: Class 'CompetitionExport_Controller' not found in /sapphire/core/control/Director.php on line 274

Can anyone provide me with what I'm doing wrong?
Everything looks fine from what I can tell based upon this page: http://doc.silverstripe.org/controller

This is with SS 2.3.2.

Avatar
Sean

Forum Moderator, 922 Posts

19 October 2010 at 11:37am

Edited: 19/10/2010 11:38am

You need to add ?flush=1 or ?flush=all to the end of the URL, the class hasn't loaded yet...

Also the controller should be in a file named "CompetitionExport.php" not "CompetitionExport_Controller.php".

Cheers,
Sean

Avatar
ImacSS

Community Member, 35 Posts

19 October 2010 at 1:07pm

Oh man - forgot about the name of the file. That was my problem.

Thanks for the answer Sean.