Adding property in all Contrellers: MY_Controller vs BaseController |
12-06-2018, 05:53 AM
(This post was last modified: 12-06-2018, 08:42 AM by Balenus. Edit Reason: code fix )
I would like each controller in my app to have a property called $controller_url that I would set to
$this->config->item('base_url') . $this->uri->segment(1); In this way in each controller I will always have the controller url ready to be passed to views. What's the best practice to do this? Should I add an application/core/MY_Controller.php Code: class MY_Controller extends CI_Controller , or should I simply create a sort of base controller and extends all my controllers from that one i.e. application/controllers/basecontroller.php Code: class BaseController extends CI_Controller What do you think? |
Messages In This Thread |
Adding property in all Contrellers: MY_Controller vs BaseController - by Balenus - 12-06-2018, 05:53 AM
RE: Adding property in all Contrellers: MY_Controller vs BaseController - by dave friend - 12-06-2018, 08:13 AM
RE: Adding property in all Contrellers: MY_Controller vs BaseController - by Balenus - 12-06-2018, 08:52 AM
RE: Adding property in all Contrellers: MY_Controller vs BaseController - by dave friend - 12-06-2018, 09:07 AM
|