Welcome Guest, Not a member yet? Register   Sign In
Strange behaviour with custom library, my mistake?
#5

[eluser]Aken[/eluser]
I just tried to load a library in a view using the latest dev version of CodeIgniter and it did not work properly. I'm gonna look into this and try and see why.

Edit:

So inside a view, the $this variable is assigned to the CI_Loader class, not the super object. If you load a library in the view, the library loads properly, but is not accessible to the scope of CI_Loader.

Like you, I was under the impression that $this within a view offered global access, but it doesn't. Maybe that can be amended to the user guide if it hasn't been yet, but CI is functioning as it should by throwing errors.

If you really want to do it this way, you should use the $ci =& get_instance() method. However, as others have mentioned, loading libraries and such is best done in the controller, since that is a more appropriate MVC style.


Messages In This Thread
Strange behaviour with custom library, my mistake? - by El Forum - 04-24-2012, 02:49 PM
Strange behaviour with custom library, my mistake? - by El Forum - 04-24-2012, 03:45 PM
Strange behaviour with custom library, my mistake? - by El Forum - 04-24-2012, 03:56 PM
Strange behaviour with custom library, my mistake? - by El Forum - 04-24-2012, 04:01 PM
Strange behaviour with custom library, my mistake? - by El Forum - 04-24-2012, 11:25 PM



Theme © iAndrew 2016 - Forum software by © MyBB