Issues trying to load a model from my controller

Ok i may be doing this the codeigniter way and there may be a different/better way to do this in fuelcms, but i am just trying to load a model from a controller and I am getting the error:

Fatal error: Class 'Base_module_model' not found in /Users/tomcaflisch/Sites/CampbellCustomCoatings-new/trunk/campbellcustomcoatings/fuel/application/models/pattern_categories_model.php on line 3

Here's my controller:
<?php if (!defined('BASEPATH')) exit('No direct script access allowed'); Class Pattern_categories extends CI_Controller { function __construct() { parent::__construct(); } function index($categoryId = null) { // set your variables $vars = array('page_title' => 'Check out our list of patterns | Campbell Custom Coatings'); if(!is_null($categoryId)) { //$this->load->model('pattern_categories_model'); // IF I UNCOMMENT THIS LINE I GET THE ERROR //$vars['patterns'] = $this->pattern_categories->get_patterns_by_id($categoryId); } // use Fuel_page to render so it will grab all opt-in variables and do any necessary parsing $page_init = array('location' => 'pattern_categories', 'render_mode' => 'cms'); $this->load->module_library(FUEL_FOLDER, 'fuel_page', $page_init); $this->fuel_page->add_variables($vars); $this->fuel_page->render(); } }

The start of my model looks like this:

<?php if (!defined('BASEPATH')) exit('No direct script access allowed'); class Pattern_categories_model extends Base_module_model { public $record_class = 'Pattern_category'; function __construct() { parent::__construct('pattern_categories'); }

Comments

  • I think i figured it out. I created a new model that extends MY_model and not Base_module_model and it works.

    I take it the problem is that I cannot use a model that extends Base_module_model because those are used for the admin side of things correct?
  • edited 1:44PM
    You can still use them but you'll need to include the base_module_model before you can extended it.
  • How do I include the base_module_model? My module works fine with this model it's just when I try to call this model from a controller it's throwing the error.
  • edited 1:44PM
    You will need to add a require_once statement including it like so:
    require_once(FUEL_PATH.'models/base_module_model.php');
  • Why didn't I need to include this file to make my module work in the admin?
  • edited 1:44PM
    The model class is probably already required in by a different model and so you don't get the error. It's best to include it at the top just in case.
  • Ok thanks.
  • edited 1:44PM
    Here is the response by the server :
    Fatal error: Class 'CI_Model' not found in /Users/michaelsilvestre/git/hightech5/fuel/application/core/MY_Model.php on line 35
  • edited 1:44PM
    Do you have any code to show how you produced that?
  • edited 1:44PM
    i'm having the same problem too now and also get the same error like rsilvestre:

    Fatal error: Class 'CI_Model' not found in /Users/..../core/MY_Model.php on line 35

    does anyone know what i'm doing wrong?
  • edited 1:44PM
    Is this with a straight install without modifications?
Sign In or Register to comment.