I am trying to extend a controller with my own class which extends the default CI_Controller class. Except it doesn’t work.
It says it can’t find my sub-class. My subclass is located in application/core and is named My_Control_Panel.
My class that extends on my sub-class:
if (!defined('BASEPATH')) exit('No direct script access allowed');
class Developers extends My_Control_Panel
{
public function __construct()
{
parent::__construct();
$this->load->helper('form');
$this->load->helper('url');
$this->load->database();
$this->checkIfLoggedIn();
$this->checkIfAllowedToViewPage();
}
My sub-class:
if (!defined('BASEPATH')) exit('No direct script access allowed');
class My_Control_Panel extends CI_Controller
{
public function __construct()
{
parent::__construct();
}
}
It keeps saying it can’t find my sub-class, while it should work.
you should name your file like this
My_Controller.phpinside yourcorefolderand then you type your code like
and this is the right way to do it in CodeIgniter, not as mentioned in the first answer with the include one ..