Calling a model from a controller from the 404 route [migrated]
- by IrishRob
Got a problem here where I can’t seem to load a method from a model after the page has been redirected after encountering a 404.
Model name: Category_Model
Method name: get_category_menu()
In my routes, I’ve updated the 404 over-ride to: $route[‘404_override’] = ‘whoops’;
I’ve also got my controller Whoops that reads…
<?php
class Whoops extends CI_Controller
{
function index()
{
$this->load->model('Category_Model');
$data['Categories'] = $this->Category_Model->get_category_menu();
$data['main_content'] = $this->load->view('messages/whoops', null, true);
$this->load->view('includes/template', $data);
}
}
So when I navigate to a page that doesn’t exist, I get the following error…
Message: Undefined property: Whoops::$Category_Model
Filename: controllers/whoops.php
I’ve hard coded the loading of the model into the controller here, even though I have it in my autoload, but no luck.
Everything else with the site so far works, just this 404 problem. Any pointers would be great, kinda new to CI so go easy on me.
Cheers.