Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/jsf/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Codeigniter 加载器类视图代码点火器_Codeigniter - Fatal编程技术网

Codeigniter 加载器类视图代码点火器

Codeigniter 加载器类视图代码点火器,codeigniter,Codeigniter,在codeigniter systems core loader.php中有一个$this->\u ci\u view\u path=array(APPPATH.views/'=>TRUE)功能 如果我想将路径更改为$this->\u ci\u view\u paths=array(APPPATH.views/template'=>TRUE)函数 我是否能够在MY_Loader.php中执行此操作?它是否会覆盖默认位置 我有hmvc,但没有更改视图路径 public function view(

在codeigniter systems core loader.php中有一个$
this->\u ci\u view\u path=array(APPPATH.views/'=>TRUE)功能

如果我想将路径更改为
$this->\u ci\u view\u paths=array(APPPATH.views/template'=>TRUE)函数

我是否能够在MY_Loader.php中执行此操作?它是否会覆盖默认位置

我有hmvc,但没有更改视图路径

public function view($view, $vars = array(), $return = FALSE) {
        list($path, $_view) = Modules::find($view, $this->_module, 'views/template/');

        if ($path != FALSE) {
            $this->_ci_view_paths = array($path => TRUE) + $this->_ci_view_paths;
            $view = $_view;
        }

        return $this->_ci_load(array('_ci_view' => $view, '_ci_vars' => $this->_ci_object_to_array($vars), '_ci_return' => $return));
    }

因为我希望能够做到这一点,
$this->load->view('user/user\u list',$data)而不是
$this->load->view('template/user/user\u list',$data)

我以前做过这个。我希望“视图”目录进入主公共html目录

我就是这样做的(在应用程序文件夹的核心目录中创建一个新文件(MY_Loader.php)

然后,我可以将视图文件夹移动到我想要的任何位置(FCPATH.'views/)


我从不建议编辑系统文件。如果需要更改任何内容,只需扩展该类。

现在可以正常工作
$this->\u ci\u view\u paths=array(APPPATH.'views/template/'=>TRUE)
class MY_Loader extends CI_Loader {

    public function __construct()
    {
        $this->_ci_view_paths = array(FCPATH . 'views/' => TRUE);
        $this->_ci_ob_level  = ob_get_level();
        $this->_ci_library_paths = array(APPPATH, BASEPATH);
        $this->_ci_helper_paths = array(APPPATH, BASEPATH);
        $this->_ci_model_paths = array(APPPATH);

        log_message('debug', "MY_Loader Class Initialized");
    }       

}