|
本帖最后由 stone_fine 于 2010-11-8 11:23 编辑
我在CodeIngiter中使用hooks实现多语言切换,但是当加载hooks时就报Message: Undefined property: Membership_modeldb错误,这是为什么,谢谢各位啊。但是把hooks去掉就正常,而且我在autoload.php中也加载了database.
挂钩点文件Languageclass.php,以下是代码:
<?php
class LangClass extends Controller {
function set_lang() {
$my_lang = $this->uri->segment(1);
if ($my_lang=='english' || $my_lang=='chinese')
{
$this->config->set_item('language', $my_lang);
}
}
}
hooks.php中的代码:
<?php
$hook['pre_controller'] = array(
'class' => 'LanguageClass',
'function' => 'set_lang',
'filename' => 'Langclass.php',
'filepath' => 'hooks',
);
Controller中的代码:
<?php
class Blog extends Controller {
function Blog() {
parent::Controller();
}
function index() {
$this->load->model('Article_model');
$this->lang->load('blog');
$data['title'] = lang('blog_title');
$data['heading'] = lang('blog_heading');
$data['copyright'] = lang('blog_copyright');
}
}
|
|