我在CodeIgniter HMVC中设置了两个模块。一个是模板,另一个是测试。从CodeIgniter中的另一个模块加载控制器HMVC
这里的文件夹结构..
- 模板
- 控制器
- home.php
- -----
- ----。 php
- 视图
- 布局
- admin.php的
- main.php
- user.php的
- 布局
- home.php
- 控制器
- 测试 个
- 控制器
- test.php的
- 控制器
我在routes.php文件哪些路由home.php作为模板的默认控制器增加了一个路线变量。并自动加载模板库。
现在,当我访问http://mysite.com/templates/home/index或http://mysite.com/templates/ ..它工作正常,但是当我运行另一个模块(测试)它显示错误。我也试过echo Modules::run('templates/home/index');
但同样的问题。我有流动的代码在测试。PHP
<?php if (! defined('BASEPATH')) exit('No direct script access allowed');
class Test extends MX_Controller {
public function index()
{
$this->load->module('templates');
$this->templates->index();
}
}
它说Unable to load the requested file: home.php
这里是我的模板库
<?php
if (!defined('BASEPATH'))
exit('No direct script access allowed');
class Template {
private $template_data = array();
private $headers = array();
private $CI;
public function __construct() {
$this->CI =& get_instance();
$this->CI->config->load('template');
}
function set($name, $value) {
$this->template_data[$name] = $value;
}
function add_header($header) {
array_push($this->headers, $header);
}
function load($template = '', $view = '', $view_data = array(), $return = FALSE) {
$this->CI = & get_instance();
$this->set('contents', $this->CI->load->view($view, $view_data, TRUE));
$this->set('headers', implode('', $this->headers));
return $this->CI->load->view($template, $this->template_data, $return);
}
}
/* End of file Template.php */
/* Location: ./system/application/libraries/Template.php */