use default controller for controller not found |
[eluser]fijiaaron[/eluser]
I want to treat the first uri segment as a method for the default controller if it doesn't map to a controller. example (assuming index.php removed via rewrite): 1. -- invoke Foo controller index() method 2. [url=]http://server/foo/bar -- invoke Foo controller bar() method 3. -- invoke default controller (Foo) index() method 4. [url=]http://server/bar -- invoke default controller (Foo) controller bar() method unless Bar controller exists Does this capability already exist? If not, I'd propose creating it by extending Router. It looks like I could add this to _validate_request (and modify the logic a bit) Code: // Look for a method in the default controller that matches? Any comments, pitfalls?
[eluser]fijiaaron[/eluser]
That not a very generalized solution. And it doesn't work if you have a 404 for any other reason.
[eluser]richthegeek[/eluser]
sorry, I figured it would be obvious that suggestion included "if the method exists within the default controller".
[eluser]fijiaaron[/eluser]
I don't follow. Do you mean edit the function show_404() to check the default controller?
[eluser]ntheorist[/eluser]
have a look at a extending router class i just posted here. It falls back like you mention http://server/bar becomes http://server/foo/bar if 'bar' is not a controller, controller sub-directory (any depth), module controller or module controller sub-directory it may need some work but so far its working for me the other way to do it is to manually set routes in your config Code: $routes['default_controller'] = 'home'; n |
Welcome Guest, Not a member yet? Register Sign In |