Welcome Guest, Not a member yet? Register   Sign In
Calling a model from a controller from the 404 route
#1

[eluser]Unknown[/eluser]
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...

Code:
<?php

class Whoops extends CI_Controller
{


public function __construct()
{
  parent::__construct();
}


function index()
{

  // Get the category data for the category menu
  $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.




Theme © iAndrew 2016 - Forum software by © MyBB