Welcome Guest, Not a member yet? Register   Sign In
How To Sub Class An Existing Controller
#2

[eluser]TheFuzzy0ne[/eluser]
Welcome to the CodeIgniter forums!

Yes you can, and it's rediculously easy to achieve! Just include the file you want to extend at the top of your controller:

./application/core/MY_Controller.php
Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed!');

class MY_Controller extends CI_Controller {
    /* ... */
}

./application/controllers/PropertyBase.php
Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed!');

class PropertyBase extends MY_Controller {
    /* ... */
}

./application/controllers/PropertyContractor.php
Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed!');

include APPPATH . 'controllers/PropertyBase' . EXT; // Ta-da!

class PropertyContractor extends PropertyBase {
    /* ... */
}

Hope this helps.


Messages In This Thread
How To Sub Class An Existing Controller - by El Forum - 05-22-2013, 08:40 PM
How To Sub Class An Existing Controller - by El Forum - 05-23-2013, 07:39 AM
How To Sub Class An Existing Controller - by El Forum - 05-23-2013, 09:14 PM



Theme © iAndrew 2016 - Forum software by © MyBB