Benbob
Benbob

Reputation: 14254

Codeigniter not finding the controller

This is my basic file structure

/system
- /application
- /config
- - -routes.php
- /controllers
- - -about.php
- - -home.php
- - /admin
- - - -dashboard.php
- - - -login.php
- - - -news.php

And in routes:

$route['admin']        = 'admin/dashboard'; //This should be the default.
$route['admin/(:any)'] = 'admin/$1';

Browsing to http://mywebsite.com/admin results in this error;

An Error Was Encountered

Unable to load the requested file: dashboard.php

I've read the documentation on controllers and sub-folders are supported. What am I doing wrong here?

Upvotes: 2

Views: 687

Answers (2)

philm
philm

Reputation: 134

Only because the someone has fubar'd the proper folder structure, there should be a 'views' folder which would avoid any confusion :/

Upvotes: 1

Benbob
Benbob

Reputation: 14254

The file dashboard.php was a view, not a controller.

I had a line $this->view->load('no/folder/here/dashboard.php'); which was throwing the error.

It's probably a good idea to name all the view files view_dashboard.php to help identify which file does what.

Upvotes: 1

Related Questions