[eluser]lexusgs430[/eluser]
Question for ya regarding extending the main MX_Controller file.
Im reusing the same exact function in a good number of my modules. Id like to be able to make this function globally accessible from any module, as I use it to set and add variables within the module classes. (as I am using modules as objects in most instances) -- I cant figure out how I can do it, I tried adding the function to the main MX_Controller but it doesen't seem to inherit properly. Can anyone tell me what I am doing wrong here?
Code:
public function __call($name, $arguments) {
if (substr($name,0,4) == 'set_') {
$property = substr($name,4);
$this->$property = $arguments[0];
} else if (substr($name,0,4) == 'add_') {
$property = substr($name,4);
array_push($this->$property, $arguments[0]);
}
return $this;
}
And just to clarify, I want to be able to set the variables of modules after they have been created as objects, using that method. For example:
Code:
$this->load->module('example');
$e = new Example();
$e->set_outputtext('I am the example module');
echo $e->outputtext;
And I dont want to have to include the previous function within the example module itself.
Any ideas as how to do it?