CodeIgniter icon indicating copy to clipboard operation
CodeIgniter copied to clipboard

when use custome routes(default_controller & 404_override), meet some error

Open wenpeng opened this issue 11 years ago • 3 comments

route setting:

$route['default_controller'] = 'home'; $route['404_override'] = 'home/dispatcher';

Default Home controller:

class Home extends CI_Controller { public function __construct(){ parent::__construct(); } public function index(){ $this->load->view('welcome_message'); } public function dispatcher(){ debug('xxx'); } }

Then make a dir 'example' and create a new empty controller Home, so, as CI3's features, this controller will be default controller of current dir. Let's visit the uri example/something, the 'something' method is not exist,so the default 404 route 'home/dispatcher', should be active,but it's meet error:

Message: call_user_func_array() expects parameter 1 to be a valid callback, class 'Home' does not have a method 'dispatcher' Filename: core/CodeIgniter.php Line Number: 514

wenpeng avatar Apr 20 '15 02:04 wenpeng

You said it:

this controller will be default controller of current dir

When you're under the example/ directory, it's example/Home.php that will be used.

narfbg avatar Apr 20 '15 08:04 narfbg

I'm currently on the same boat. i can't change "default_controller" that exist on subfolder on CI3.

config.php $route['default_controller'] = 'user/login';

/controller/user/login.php class login extends CI_Controller { public function index() { $this->load->view('welcome_message'); } }

please help, gbu :)

seputrodimas avatar Apr 29 '15 15:04 seputrodimas

It simply doesn't work in the way you want it to. Nobody can help you with that.

narfbg avatar Apr 29 '15 15:04 narfbg