Een voobeeld:
Normaliter moet je eerst doen:
Code: Select all
$this->load->model('account/address');
Code: Select all
$this->model_account_address->getAddresses();
Code: Select all
$this->model_account_address->getAddresses();
De enige aanpassing die hier voor nodig is in system/engine/registry.php is deze functie:
Code: Select all
public function get($key) {
return (isset($this->data[$key]) ? $this->data[$key] : NULL);
}
Code: Select all
public function get($key) {
if(!isset($this->data[$key])){
$parts = explode('_', $key);
if(isset($parts[0])){
switch ($parts[0]){
case 'mail' :
$this->data['load']->library('mail');
$this->set('mail', new Mail());
break;
case 'model' :
array_shift($parts);
$this->data['load']->model(implode('/', $parts));
break;
}
}
}
return (isset($this->data[$key]) ? $this->data[$key] : NULL);
}
Hierdoor kan een site wat sneller laden, want er word alleen geladen wat nodig is, en dat is bij bv ajax aanroepen wel prettig.
Happy coding ;-)