File not recognizing Model For Some Reason

edited October 2013 in Modules
I created a module for my home page called "homeslider". Where basically someone can upload an image location and image content to the database by way of fuel admin. That part works. The information is saved to the database. Now I want to reference the table data on the home page.

Now the home page (home.php) is in view and it pulls most of the view from the blocks (_blocks/header.php and _blocks/footer.php). Now in home.php I'm trying to pull from the homeslider table so I reference the model file homeslider_model.php. Here's that code:

<?php fuel_set_var('layout', 'main'); ?>



<?php

$CI = & get_instance();
$CI->load->model('homeslider_model');

$values = $this->homeslider_model->find_all();

//var_dump($values);
?>



However, I'm getting this error:

Severity: Notice

Message: Undefined property: MY_Loader::$homeslider_model

Filename: fuel/Loader.php(298) : eval()'d code

Line Number: 10

I'm almost stumped on this one because it looks like I'm doing everything right.

Comments

  • edited October 2013
    You need to reference $CI->homeslider_model->find_all() instead of $this->homeslider_model->find_all().
  • edited 11:53AM
    That solved it. Thanks. Now in the homeslider_model.php, I can create functions that grabs the data? Like for instance, function getImage( ). Or does FUEL through Base_module_model already have functions I can use?
  • edited 11:53AM
    You can add additional methods to your model if you need to. However, the returned result set will most likely be an array of objects that probably have an "image property on them:
    $values = $CI->homeslider_model->find_all(); foreach($values as $val) { echo $val->image; }
Sign In or Register to comment.