insomiac
insomiac

Reputation: 5664

Not to load an autoload library in codeigniter

I have a library which is used by all controllers. But for a specific controller i dont want to load that library. Is there any way i can stop loading that library for that controller.

i am using this command but its failing:
$this->load->library('xyz',array('autoload' => FALSE));

Thanks

Upvotes: 0

Views: 1962

Answers (2)

minboost
minboost

Reputation: 2563

Autoloading is meant for site-global items.

A cleaner solution may be to extend the controller and load the library in that new controller's constructor. Then all of your controllers extend from that controller, except the one(s) you don't want to load that library - those can extend the original CI controller.

That should take you < 5 minutes to implement and you won't have to hack anything.

Upvotes: 3

swatkins
swatkins

Reputation: 13630

You can take a look at this link:

http://xplus3.net/2010/05/31/conditional-auto-loading-of-libraries-in-codeigniter/

Basically, you'd be overwriting the autoload.php library to check for a variable. If that variable is false, then explicitly add the specific library to the autoload array.

Upvotes: 0

Related Questions