![]() |
How to suppress load->view errors? - 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: How to suppress load->view errors? (/showthread.php?tid=25443) |
How to suppress load->view errors? - El Forum - 12-11-2009 [eluser]kilishan[/eluser] I'm in the final stages of re-writing my layout library, and am running into a problem. I want to try to load a view from the active theme and, if it wasn't found, try loading that same view from the default theme. The themes are simply folders within the /views folder. The problem is that load->view stops the controller execution and spits out an 'Unable to load the requested file: ' error. Is there a way to keep CI from doing this? I'm really wanting to use the load->view method so that the library will be compatible with module systems, like Matchbox, who replace the Loader class to work with their modules. If that wasn't a requirement, I'd simple do a file_exists(). Any ideas? Thanks. How to suppress load->view errors? - El Forum - 12-12-2009 [eluser]theprodigy[/eluser] Have you tried loading the view into a variable? Not sure if that will return an error or just set the variable to null or false or something. Either that or you can check file_exists before loading the view. How to suppress load->view errors? - El Forum - 12-12-2009 [eluser]kilishan[/eluser] Thanks for the suggestion. The first way that I had tried was seeing if it returned false, since I thought I remembered digging through the code a while back and seeing that would work. Obviously was wrong. ![]() The problem with using file_exists is that if someone is using Matchbox or HMVC the file won't be in the proper location. The only solution I can think of right now is to override the Loader class to return false. Then I'll have to provide instructions for Matchbox and HMVC users to change their Loader file. Not ideal, but I guess it's workable. |