![]() |
Set Multiple Error 404's - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Development (https://forum.codeigniter.com/forumdisplay.php?fid=6) +--- Forum: CodeIgniter 3.x (https://forum.codeigniter.com/forumdisplay.php?fid=17) +--- Thread: Set Multiple Error 404's (/showthread.php?tid=62363) |
Set Multiple Error 404's - wolfgang1983 - 07-06-2015 I use codeigniter version 3 and HMVC. When using my HMVC I have to modules one called admin and one called catalog. I would like to know if it is possible to create two $route['404_override'] = ''; one for admin and one for catalog. Because I would like different styles. Any Suggestions. Thanks in advance. RE: Set Multiple Error 404's - mwhitney - 07-06-2015 You should be able to check the requested URI in the controller specified in 404_override, then handle it accordingly. Assuming you're using Wiredesignz HMVC, if you wanted each module to specify the 404_override handler independently, you could name the 404_override controllers the same in each module and in the base application, then call the correct module's controller from the application's controller. If you want to avoid calling controllers from a controller, you can extend the MX_Router to handle this appropriately, or specify the 404_override handlers in the modules as libraries. RE: Set Multiple Error 404's - wolfgang1983 - 07-07-2015 (07-06-2015, 08:09 AM)mwhitney Wrote: You should be able to check the requested URI in the controller specified in 404_override, then handle it accordingly. Assuming you're using Wiredesignz HMVC, if you wanted each module to specify the 404_override handler independently, you could name the 404_override controllers the same in each module and in the base application, then call the correct module's controller from the application's controller. I created a My_404.php controller in the main controllers page rather than my HMVC modules and seems to detect it now. $route['404_override'] = 'my_404'; This way now I can make it work but will look more into it. At least now I can use uri segments to change theme of 404 etc. I will look more in to the MX_Router.php Thank for your advice. @mwhitney RE: Set Multiple Error 404's - ivantcholakov - 07-07-2015 You need to distinguish on reading configuration what part of the site is requested, admin or the other one. The URL brings this information. See this example from PyroCMS: https://github.com/pyrocms/pyrocms/blob/2.1/master/system/cms/config/config.php#L305 RE: Set Multiple Error 404's - ivantcholakov - 07-07-2015 $route['404_override'] = preg_match('@\/admin(\/.*|\?.*)?$@', isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '') ? 'admin_error_404' : 'front_error_404'; |