Welcome Guest, Not a member yet? Register   Sign In
I want create a Typical Controller and extends all controller from it, but CI don't find
#4

[eluser]Cro_Crx[/eluser]
Make sure that your MY_Controller is extending CI_Controller and your other classes extend MY_Controller. You'll get that error if one of your regular controllers tries to extend CI_Controller instead of its alias 'Controller'.

If you want to achieve this functionality, you can do it with a single MY_Controller class. Simply add a function to use if it's an admin page. Something like this for the Base Controller:

Code:
Class MY_Controller extends CI_Controller
{
    function MY_Controller()
    {
        parent::Controller();
        /* Perform Actions here that All Controllers will need. */

    }

    function require_admin()
    {
        /* Perform actions here required for using admin pages. */
    }

  
}

Then on your Admin Controller do something like this:

Code:
Class Admin extends MY_Controller
{
    function Admin()
    {
        parent::MY_Controller();
        $this->require_admin(); /* This makes sure our user has admin privileges. All functions within this controller will now run this.*/
    }

}


Messages In This Thread
I want create a Typical Controller and extends all controller from it, but CI don't find - by El Forum - 01-28-2010, 03:34 AM



Theme © iAndrew 2016 - Forum software by © MyBB