【发布时间】:2016-10-09 22:45:00
【问题描述】:
我正在尝试从 Codeigniter (3.1.0) 中的应用程序文件夹外部加载视图,如下所示:
public function index ( $page = '' ) {
/**
* Get active theme from DB
*/
$active_theme = $this->m->getActiveTheme();
/**
* Change default view path
*/
$this->_ci_view_paths = array(
FCPATH . 'themes/' . $active_theme . '/' => TRUE
);
/**
* Load index if page is not found
*/
if ( ! file_exists( FCPATH . 'themes/' . $active_theme . '/' . $page . '.php')) {
$this->load->view( 'index', $data );
} else {
$this->load->view( $page, $data );
}
}
但是我收到了这个错误:
无法加载请求的文件:index.php
或者我尝试加载的任何页面。
有人知道我在这里缺少什么吗?
【问题讨论】:
-
为什么文件在视图文件夹之外?为什么不包含它而不是加载它?
-
前端与后端分离。这样我就可以将 CI 换成任何其他后端。
标签: php codeigniter