Loading view outside view folder with CodeIgniter

后端 未结 7 2080
悲哀的现实
悲哀的现实 2020-12-03 12:44

I have the need to load a view from outside the scope of:

$this->load->view();

which appears to work from base/application/vie

7条回答
  •  不知归路
    2020-12-03 13:12

    Following Dino's answer and correcting the ci_vars, working as view Codeigniter's function:

    Codeigniter View Function

    public function view($view, $vars = array(), $return = FALSE)
        {
            return $this->_ci_load(array('_ci_view' => $view, '_ci_vars' => $this->_ci_prepare_view_vars($vars), '_ci_return' => $return));
        }
    

    Dino's View Function will be now:

    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_prepare_view_vars($vars),
                    '_ci_return' => $return
                ));
      }
    

提交回复
热议问题