CodeIgniter Forums

Full Version: Hi, I'm trying to learn, but I'm in trouble. I was wondering how to globally call the
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi, I'm trying to learn, but I'm in trouble. I was wondering how to globally call the functions of a library / model by declaring it only once.

I try to explain myself better, I declare the library that I need in the controller and in the controller itself I use it. So far everything is ok.
 
But if I need to use the same function directly in a View file, do I have to declare the library again? How can I optimize this?

*The concept is that of not always wanting to repeat the appeal of libraries or models.
You don't need to declare it in the view just make the function in the controller and pass it to view as an atty of variable I guess.
If your view need to call a model, then you’re doing something wrong. The view should only render html, not querying de database.

The only exception I can see is the view-cell in CI4 where you call a function from a library that do everything and return the final HTML code to be inserted in the parent view.