[eluser]tonanbarbarian[/eluser]
I think the reason that autoload is not working in this case is that autoload is done AFTER the controller is created.
The way I have done this before is to override the Router. The advantage of this method is that you can determine which extension library is needed based on the route
libraries/MY_Router.php
Code:
<?php
if (!defined('BASEPATH')) exit('No direct script access allowed');
class MY_Router extends CI_Router {
/**
* Constructor
*/
function MY_Router() {
parent::CI_Router();
// at this point we know the current route
// so determine what libraries we need to load
if ($this->directory == 'admin/')
// admin so load the backend
load_class('Backend', false);
else
// front end
load_class('Frontend', false);
} // MY_Router()
} // class MY_Router
Since the Router knows where we need to go immediately after it is instanciated we can just check the directory and if it is 'admin/' or whatever else you want, we know to load the appropriate class.
We use load_class rather than $CI->load->library because at this point there is not controller instanciated.
The 2nd parameter of load_class being set to false will ensure that the class is loaded but not instanciated.