Don't know whether it's a correct way, but it works :)
In your application/core
folder put this loader extention
<?php
class MY_Loader extends CI_Loader {
function ext_view($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
));
}
}
?>
Then you want a external view file, suppose its in the third_party folder
application/third_party/my_new_view.php
Hello : <?php echo $my_name; ?>
Then call your new view in the controller
ext_view is your new view loader method,
- 1st param : the folder inside you applicaton
- 2nd param : the view name
- 3rd param : the variables data and so on...
test_controller.php
$view_data = array('my_name' => 'dino');
$this->load->ext_view('third_party', 'my_new_view', $view_data);
If everything fine. it will output
Hello : dino
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…