I have created an admin controller that extends the blog controller (both are located in application/controller). However, when I tried to access the controller, it gives me an error that the blog controller was not found. If I put require_once(APPPATH.'controllers/blog.php'); inside the admin.php file it works. But I'm just wondering if there's another possible way to extends the blog controller without having to use require_once inside the admin.php
Add a comment
|
1 Answer
From CI user guide
If you are extending the Controller core class, then be sure to extend your new class in your application controller's constructors.
class Welcome extends MY_Controller { function __construct() { parent::__construct(); } function index() { $this->load->view('welcome_message'); }}
That means your Blog controller must extends CI_Controller
Example:
class MY_Blog extends CI_Controller {
function hello() {
$data = 'something';
}
}
class Admin extends MY_Blog {
function do_something() {}
}