In Modular Codeigniter, how can/should one module's controller call another module's function?
You can load the model articles
from module articles
from another module Dashboard
.
Just load the model in the constructor function of the module (ex. Dashboard
) you want the model to be available which should look like this.
function __construct() { parent::__construct(); ... // this is case sensitive, 1st part is the module, 2nd part is the class name $this->load->model('articles/Articles');}
Then anywhere in your controller (ex. Dashboard
), you can call $this->articles_model->update_article();
.