![]() |
strange routing error? Autoload not being called on some 404's. - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: strange routing error? Autoload not being called on some 404's. (/showthread.php?tid=29804) Pages:
1
2
|
strange routing error? Autoload not being called on some 404's. - El Forum - 04-21-2010 [eluser]gRoberts[/eluser] Hi everyone, I've setup all of my error_* documents that include my site header and footer. The header and footer uses the base_url() call, so I have set it up to autoload the URL helper. When I go to an url where the controller exists but the action doesn't, all works fine, the error page shows. If I go to a an url where the controller does not exist, I get "Call to undefined function base_url()" Any idea's? I tried using get_instance and then loading the helper manually in the header and it fails on "Call to undefined function get_instance()" Any idea's? Cheers Gav strange routing error? Autoload not being called on some 404's. - El Forum - 04-21-2010 [eluser]Bart v B[/eluser] maybe some code should be nice. ![]() Then it's easyer to help. strange routing error? Autoload not being called on some 404's. - El Forum - 04-21-2010 [eluser]gRoberts[/eluser] autoload.php Code: $autoload['helper'] = array('url'); error_*.php Code: <? include(APPPATH . '/views/common/header.php'); ?> header.php Code: <img src="<?= base_url(); ?>assets/images/logo.png" alt="Company name" title="Company name" /> Theres not really much to see. Cheers strange routing error? Autoload not being called on some 404's. - El Forum - 04-22-2010 [eluser]gRoberts[/eluser] Might be a bug. I've been able to replicate it on another site. Error output: Code: DEBUG - 2010-04-22 07:07:32 --> Config Class Initialized strange routing error? Autoload not being called on some 404's. - El Forum - 04-30-2010 [eluser]gRoberts[/eluser] Anyone got any idea's before I make this a bug? strange routing error? Autoload not being called on some 404's. - El Forum - 04-30-2010 [eluser]danmontgomery[/eluser] Neither of these are bugs... The 404 page is thrown when the router class is loaded, on line 99 of CodeIgniter.php. get_instance() is defined when Base4.php or Base5.php are included (line 140 or 144 of CodeIgniter.php) and autoload is run when the Controller class is declared (line 148 of CodeIgniter.php). As for the log with a seemingly non-functioning router, there is either a problem with your controller or routing that is causing the page not to be found. strange routing error? Autoload not being called on some 404's. - El Forum - 04-30-2010 [eluser]gRoberts[/eluser] The site is a vanilla setup of CI 1.7.2. No changes to the route.php, no MY_router.php, etc. If it's not an error. Are you/CI suggesting we all use absolute url's on our error pages? Thanks for your help! strange routing error? Autoload not being called on some 404's. - El Forum - 04-30-2010 [eluser]danmontgomery[/eluser] Whether you use absolute or relative paths have nothing to do with whether or not you use the url helper or the CI super object... I'm saying if the controller doesn't exist execution is halted before you have access to these things. If you need to use CI functionality in the 404 page, I'd suggest you use _remap or a catch-all route at the bottom of routes.php to redirect any 404s to your own 404 controller. strange routing error? Autoload not being called on some 404's. - El Forum - 04-30-2010 [eluser]CroNiX[/eluser] Here is a good article on a 404 controller that lets you use the CI superglobal. I use this in all of my projects so I can generate dynamic 404 pages (like getting data from the db, logging the 404 in the database, etc). http://maestric.com/doc/php/codeigniter_404 strange routing error? Autoload not being called on some 404's. - El Forum - 05-03-2010 [eluser]gRoberts[/eluser] I find it disappointing that the functionality isn't consistent. If the functionality exists, it should work in both instances. That said, I understand that the autoloader isn't loaded until a certain point. So I would need to use absolute URL's in my header/footer. This just makes it harder to move the site, despite the framework promoting portability. Thanks everyone! |