Welcome Guest, Not a member yet? Register   Sign In
Can I create two extended controller classes? (solved)
#1

[eluser]laytone[/eluser]
I usually extend my controller and add a _showPage() function to display my data in a template from any controller. I also keep track of other things in my extended controller (MY_Controller)

My question is this:

I want to create an area of my site that is a little different than the rest (i.e. an admin area)

How can a create a second extended controller?

This is what I have:

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

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

And I would like to do this to:

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

Code:
class Site_admin extends MY_Admin_controller(){
function __construct(){
  parent::__construct();
}
}

Can this be done? I would like to add my auth code and stuff in my 'MY_Admin_controller' class and house the admin controllers in a directory like this 'controllers/admin/controllers.php'
#2

[eluser]flaky[/eluser]
Yes you can do this
#3

[eluser]laytone[/eluser]
How,

When I attempted it I got a fetal error.

Fatal error: Class 'MY_Admin' not found in C:\Users\**ME**\Project Folder\**My Project**\application\controllers\sitetest.php on line 3

Code:
class Sitetest extends MY_Admin { //This is line 3
    
    public function __construct() {
        parent::__construct ();
    }
#4

[eluser]flaky[/eluser]
you need to make an inclusion of the controller you are extending

example
Code:
include_once APPPATH . "controllers/main" . EXT;

class Test extends Main{
}
#5

[eluser]laytone[/eluser]
I thank you much! ... I should have known that... Big Grin




Theme © iAndrew 2016 - Forum software by © MyBB