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.
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