Reputation: 887
I have a custom CodeIgniter library class that I create an instance of in a controller. This controller calls a view, and I want to be able to access this instance of the library from the view. I do not want to 're-load' the library, because it would create a new instance.
More specifically, I want to access the class variables in my view ($this->varname).
Is this possible?
Should I be doing this?
Thanks in advance.
Upvotes: 2
Views: 1285
Reputation: 2355
Yes Ben, it's possible and probs a good idea? Here's a helpful pointer: call my own library within a view in codeigniter
Upvotes: 0
Reputation: 38238
Have you implemented your library class as a normal custom library (e.g. as a library in your application/libraries folder)? If so, then loading it as a library like normal in the constructor of your controller (e.g. $this->load->library('your_custom_library');
) will make that same instance available in your view, as $this->your_custom_library
.
Upvotes: 3