views:

41

answers:

2

I want to create two parent controllers: one for admin and one for user site. They have to extend a regular Controller class but each of them has to do different things.

A: 

You can make a MY_AdminController and a MY_UserController in system/application/libaries and use those to extend the rest of your controllers.

E.g.:

class Register extends MY_UserController
{
    // Implementation
}

And:

class ManageUsers extends MY_AdminController
{
    // Implementation
}
captaintokyo
Thank you captaintokyo for suggestion but this does not work it says My_UserController and MY_AdminController not found...
Tamik Soziev
put your My_UserCrontroller and My_AdminController into /system/application/libraries
ITroubs
Where did you put `MY_AdminController` and a `MY_UserController`? I tried what I described above and it works fine.
captaintokyo
+2  A: 

I wrote up an article showing how you do this.

http://philsturgeon.co.uk/news/2010/02/CodeIgniter-Base-Classes-Keeping-it-DRY

You need to create an __autoload() function in your config.php or directly include the base controller above the class definition.

Phil Sturgeon