I have the need to load a view from outside the scope of:
$this->load->view();
which appears to work from base/application/vie
To customize models and views outside the 'application'
folder, follow these easy steps,
Create My_Loader.php
file in 'application/core'
directory
Copy the code into the custom My_Loader.php
class MY_Loader extends CI_Loader {
function mymodel($model, $folder = '',$vars = array(), $return = FALSE) {
array_push($this->_ci_model_paths, ""); //replace "" with any other directory
parent::model($model);
}
function myview($folder, $view, $vars = array(), $return = FALSE) {
$this->_ci_view_paths = array_merge($this->_ci_view_paths, array(APPPATH . '../' . $folder . '/' => TRUE));
return $this->_ci_load(array(
'_ci_view' => $view,
'_ci_vars' => $this->_ci_object_to_array($vars),
'_ci_return' => $return
));
}
Save the file and in the controller, call and load the model (which resides outside the application folder) as,
$this->load->mymodel('folder/model');
and for the view,
$this->load->myview('views','view_dir/view-php-file', $data);