douyun7285 2015-11-10 09:21
浏览 77
已采纳

移动到托管服务器时,调用未定义的方法CI_Loader :: template()

I am using CI 3 and all functions area working in my local server.

But when i uploaded it to the webhosting server it give me this error:

  Call to undefined method CI_Loader::template()

My controller "Main.php" has the code:

 class Main extends CI_Controller {
    function __construct() {
        parent::__construct();                  
        /* enable session */            
        //$this->output->enable_profiler(TRUE);             
    }

    public function index() {
        if ( ! file_exists(APPPATH.'/views/admin/main.php'))
        {
            /* Whoops, we don't have a page for that! */
            show_404();
        }


        $data['menu'] = $this->load->view('templates/menu', $data, TRUE);                           
        $data['title'] = "EGB | Main"; 
        $this->load->template('admin/main', $data);

        //$this->load->view('admin/main', $data);                                   
    }
 }

And in the "My_Loader.php" has:

 class MY_Loader extends CI_Loader {
    public function template($template_name, $vars = array(), $return = FALSE)
    {
         if($return):
            $content  = $this->view('templates/header', $vars, $return);
            $content .= $this->view($template_name, $vars, $return);
            $content .= $this->view('templates/footer', $vars, $return);

            return $content;
        else:
            $this->view('templates/header', $vars);
            $this->view($template_name, $vars);
            $this->view('templates/footer', $vars);
        endif;
    }
}

What could be wrong?

Thanks in advance.

  • 写回答

2条回答 默认 最新

  • douxiaomang5640 2015-11-10 09:30
    关注

    Your core file names should match the class name.

    Try changing the file name to

    core/MY_Loader.php

    Instead of

    core/My_Loader.php

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制