Welcome Guest, Not a member yet? Register   Sign In
Set Multiple Error 404's
#1

(This post was last modified: 07-06-2015, 07:27 AM by wolfgang1983.)

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.
There's only one rule - please don't tell anyone to go and read the manual.  Sometimes the manual just SUCKS!
Reply
#2

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.
Reply
#3

(This post was last modified: 07-07-2015, 12:56 AM by wolfgang1983.)

(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.

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.

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
There's only one rule - please don't tell anyone to go and read the manual.  Sometimes the manual just SUCKS!
Reply
#4

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/...g.php#L305
Reply
#5

(This post was last modified: 07-07-2015, 10:42 AM by ivantcholakov.)

$route['404_override'] = preg_match('@\/admin(\/.*|\?.*)?$@', isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '') ? 'admin_error_404' : 'front_error_404';
Reply




Theme © iAndrew 2016 - Forum software by © MyBB