Calling function in superclass but using model in current class |
[eluser]Mr.Data[/eluser]
Hello! I have a function which is used in several classes. So my idea is to put this function into the upper class MY_Controller. Now it looks something like this Code: class Super_Controller extends CI_Controller {
[eluser]JoostV[/eluser]
Simply load the model inside your super class. Code: class Super_Controller extends CI_Controller { By the way, you might like the MY_Controller video tutorial at http://codeigniter.tv/a-10/Extending-the...and-beyond
[eluser]Mr.Data[/eluser]
The used model is dependent on the subclass. OK, but I could pass it as a parameter. But I am also using several calls to others functions. Look at this: Code: class Super_Controller extends CI_Controller { Code: parent::doSomething($target, &$this);
[eluser]JoostV[/eluser]
$this->input->post('submit') is available in all controllers. No need to pass $this.
[eluser]Mr.Data[/eluser]
OK, passing the model to the superclass was the solution to this problem. Now everything is fine. |
Welcome Guest, Not a member yet? Register Sign In |