MY_Controller.php(application / core):
<?php
class MY_Controller extends CI_Controller
{
public $data = array();
function __construct()
{
parent::__construct();
$this->data['errors'] = array();
$this->data['my_site_name'] = config_item('site_name');
}
}
Frontend_Controller.php(application / libraries)
<?php
class Frontend_Controller extends MY_Controller
{
function __construct()
{
parent::__construct();
}
}
pages.php(应用程序/控制器)
class Pages extends Frontend_Controller {
function __construct()
{
parent::__construct();
$this->load->model('app_model');
}
public function index()
{
$this->view_data['main_content'] = 'frontpage';
$this->load->view('template', $this->view_data);
}
}
页面被设置为路由中的默认路由,如果我尝试加载名为testmodule的HMVC模块,如http://localhost/testmodule
,则效果很好。
但是,当我想要回显这个模块时(索引方法只包含一行
) echo "Welcome from testmodule!";
)喜欢:
<div class="page">
<?php $this->load->view('includes/block_left') ?>
<div id="content">
<div>
<?php
echo modules::run('testmodule');
?>
<?php $this->load->view('articles_new'); ?>
</div>
</div><!-- /content -->
</div>
我收到此错误:
Fatal error: Cannot redeclare class CI in C:\wamp\www\application\third_party\MX\Base.php on line 57
编辑:
如果我试图改变
class MY_Controller extends CI_Controller
到
class MY_Controller extends MX_Controller
我收到了这个错误:
An Error Was Encountered
Unable to load the requested file:
知道出了什么问题吗? ;(