Welcome Guest, Not a member yet? Register   Sign In
How to suppress load->view errors?
#1

[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.
#2

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

[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. Smile So I currently have it returning to a variable and checking for an empty string. No dice there, either.

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.




Theme © iAndrew 2016 - Forum software by © MyBB