Welcome Guest, Not a member yet? Register   Sign In
Extending the controller class
#4

[eluser]kaejiavo[/eluser]
[quote author="ricardino" date="1287523660"]thanks for the help, ive tried the suggestions mentioned there, but still no luck. so far i have:

a MY_Controller:

Code:
class MY_Controller extends Controller {
    
    function __construct() {
        parent::Controller();
    }
    
    
}

A Site_Controller:

Code:
class Site_Controller extends MY_Controller{
    
    function __construct() {
        parent::MY_Controller();
        
    }

and an Admin_Controller:

Code:
class Admin_Controller extends MY_Controller {

    function Admin_Controller() {
        parent::MY_Controller();
    }

but still no luck, it should be noted that if simply extend my usual controllers directly from the Controller class, they work without a hitch, so my code is ok. Also on a slightly different note, what is the purpose of this :

Code:
function __autoload($class)
{
if(strpos($class, 'CI_') !== 0)
{
  @include_once( APPPATH . 'libraries/'. $class . EXT );
}
}

Any help would be appreciated.[/quote]

Hi,
you have to use only one file: MY_Controller.php as this will be autoloaded by CI.
Then you put all your three classes in this file, like:
Code:
class MY_Controller extends Controller {
    
    function __construct() {
        parent::Controller();
    }
        
}

class Site_Controller extends MY_Controller{
    
    function __construct() {
        parent::MY_Controller();
        
    }

class Admin_Controller extends MY_Controller {

    function Admin_Controller() {
        parent::MY_Controller();
    }

Then you can extend your Site_Controller or Admin_Controller as you like.

Marco


Messages In This Thread
Extending the controller class - by El Forum - 10-18-2010, 05:06 PM
Extending the controller class - by El Forum - 10-18-2010, 05:33 PM
Extending the controller class - by El Forum - 10-19-2010, 10:27 AM
Extending the controller class - by El Forum - 10-19-2010, 12:51 PM
Extending the controller class - by El Forum - 10-19-2010, 02:17 PM
Extending the controller class - by El Forum - 10-19-2010, 03:05 PM
Extending the controller class - by El Forum - 10-19-2010, 05:42 PM



Theme © iAndrew 2016 - Forum software by © MyBB