[Solved] Routing Question. |
I know this question problem has been asked quite a few times.
With codeigniter 3.0 + versions you are not able to have sub folders for default controller in routes.php // Not allowed $route['default_controller'] = subfolder/'welcome'; // Allowed $route['default_controller'] = 'welcome'; Has any one come up with a Custom MY_Router.php that could over ride that? to allow to have sub folders in default_controller in routes on CI3 versions? I know people say it not the norm to have it like that but would be good if could have option like what HMVC does.
There's only one rule - please don't tell anyone to go and read the manual. Sometimes the manual just SUCKS!
Only the default route has this restriction, as it is the main entry point.
Why not leave the welcome controller but have a redirect to your subfolder and method you want to be the default route. That's what I am doing.
Practical guide to IgnitedCMS - Book coming soon, www.ignitedcms.com
You will need to override the _set_default_controller() method in the router class.
Create a MY_Router.php class in ./application/core and add this: PHP Code: class MY_Router extends CI_Router {
(10-31-2015, 01:37 AM)Martin7483 Wrote: You will need to override the _set_default_controller() method in the router class. That works great can it be done also for the // Working $route['404_override'] = 'not_found'; // Not Working $route['404_override'] = 'error/not_found';
There's only one rule - please don't tell anyone to go and read the manual. Sometimes the manual just SUCKS!
(10-31-2015, 12:54 AM)iamthwee Wrote: Only the default route has this restriction, as it is the main entry point. I like to have most of the controllers in sub folders inside the controllers folder keeps it nice and tidy and separated but that is my opinion. Every one has there own ideas.
There's only one rule - please don't tell anyone to go and read the manual. Sometimes the manual just SUCKS!
I would not advise doing that as you would need to edit ./system/core/CodeIgniter.php file. And it is never a good idea to edit the core files.
But if you do want to do that this should work: PHP Code: if( is_dir(APPPATH.'controllers/'.$error_class) ) { Place it after these lines, round line number 433-436: PHP Code: if (sscanf($RTR->routes['404_override'], '%[^/]/%s', $error_class, $error_method) !== 2)
(10-31-2015, 02:23 AM)Martin7483 Wrote: I would not advise doing that as you would need to edit ./system/core/CodeIgniter.php file. And it is never a good idea to edit the core files. Thanks for your help and advice
There's only one rule - please don't tell anyone to go and read the manual. Sometimes the manual just SUCKS!
|
Welcome Guest, Not a member yet? Register Sign In |