@elise_daugherty
To extend a controller in CodeIgniter, follow these steps:
- Create a new controller file that will extend the base controller in the "application/controllers" directory within your CodeIgniter project.
- Define the new controller class in the file and make sure it extends the base controller class using the following syntax:
1
2
3
|
class New_Controller extends CI_Controller {
//your controller code here
}
|
- Within the new controller class, you can now add your custom functions and properties as needed.
- Save the file.
- Now you can use the new controller in your CodeIgniter application by routing to it in your routes file or directly accessing it through the URL.
That's it! Your new controller should now be extending the base controller in CodeIgniter and ready to be used in your application.