CodeIgniter Forums

Full Version: how do you load a library for all pages in a controller?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[eluser]Abel A.[/eluser]
Lets say I want to load a library in all my pages, how would I do that instead of calling it on each function?

Example:
Code:
class login extends CI_Controller {

public function index()
{
  $this->load->helper('url');
}

public function forgot()
{
  $this->load->helper('url');

}

public function activate()
{
  $this->load->helper('url');
}

}

El Forum

[eluser]Aken[/eluser]
Do it in the constructor - __construct()

El Forum

[eluser]InsiteFX[/eluser]
As for the url_helper I would autoload it being as it is always being used!

Else do like Aken says.

El Forum

[eluser]Abel A.[/eluser]
Yeah, thanks guys. I just found the autoload feature in CI Smile