Multi-Level Codeigniter Inheritance

I am having the problem of using multi-level inheritance as follows.

I have a top level controller that extends the CI_Controller class

class Application extends CI_Controller { } 

A controller named "Site" and "Administrator" extends the application controller as

 class Site extends Application { } class Admin extends Application { } 

And finally, the class "User" and "Guest" extends the controller "Site"

 class User extends Site { } Class Guest extends Site { } 

The problem is that in the user and guest controller, I cannot load basic libraries such as pagination, form_validation, etc. using

$ this-> load-> library ('pagination');

But it works when I load the library into the site controller or application Contoller, i.e. a controller that extends the main CI_Controller and child controller. When I try to load a great child, it does not work.

Can someone find out why this is happening? Thanks...

+4
source share
3 answers

Checkout Basic CodeIgniter Controllers , including description.

+1
source

I have not seen a previously created multilevel constructor class, but it should work.

Do you call parent::__construct() in the constructor of each class?

+2
source
 //-Create MY_Controller.php on application/core/MY_Controller.php //contents of MY_Controller.php class Application extends CI_Controller{ function __construct(){ // Call the CI_Controller constructor parent::__construct(); } } //that is all now you can inherit class (Application) anywhere in your project 
0
source

All Articles