Advanved Modules - Model problems

edited March 2013 in Modules
I am trying to follow the advanced modules guide to create a module for my CMS project but am struggling to get a model to load.

Controller Code
function index()
{
$this->_validate_user('offers');
$this->load->module_config(OFFERS_FOLDER, 'offers');
$offers_config = $this->config->item('offers');
$this->load->module_model('offers','offers');
$vars['offers'] = $this->offers->getAllOffers();
$this->_render('offers_admin',$vars);
}

The error I get is
Message: Undefined property: Offers::$fuel_auth
Filename: libraries/Fuel_base_controller.php
Line Number: 31

Anyone know what I am doing wrong?

Comments

  • edited 4:32AM
    Well after some more playing I found that the issue was that the Fuel_base_controller was loading the fuel_auth library in its constructor and was then referring to it as $this->fuel_auth but could not find it. If I changed line 31 to
    $this->fuel_auth = $this->load->module_library('FUEL_FOLDER');
    It got further but then stopped in the assest_helper with a problem on jspath....

    I may well be doing something stupid wrong here but it is incredibly frustrating trying to get an advanced module to work.... May have to abandon the FUELCMS and look for an alternative.
  • edited 4:32AM
    Even more digging....... Very odd...
    I have added an echo to the fuel_base_controller constructor and found that the constructor is firing a second time when I call
    $this->load->module_model('offers','offers');
    The second time it is loading is causing it to fail...
  • edited 4:32AM
    A couple questions:

    1. What is the path and name of your controller?
    2. Can you paste in the whole code or at least up to the index method?
    2. Is this with 0.93 or the 1.0 beta version
    https://github.com/daylightstudio/FUEL-CMS/tree/1.0
  • edited 4:32AM
    Hi,
    I am using 0.93 at the moment.

    The path is fuel/modules/offers/controllers

    The whole controller is
    <?php
    require_once(FUEL_PATH.'/libraries/Fuel_base_controller.php');

    class Offers extends Fuel_base_controller {
    public $view_location = 'offers';
    public $model_name = 'offers';
    function __construct()
    {
    parent::__construct(TRUE);
    $this->_validate_user('tools/offers');
    }


    function index()
    {
    echo('Fred');
    $this->load->module_model(OFFERS_FOLDER,'offers');
    echo(' is dead!');
    // $vars['offers'] = $this->offers->getAllOffers();
    // $this->_render('offers_admin',$vars);
    }
    }
  • edited 4:32AM
    It sounds like it may be because you have a model that's the same name as your controller (2 Classes named Offers?). Try naming your controller, Offers_module. This will automatically be picked up by FUEL without the need for a route in your fuel/modules/offers/config/offer_routes.php file.
  • edited 4:32AM
    Yup..... Thank you very much.... Hopefully that will be my Doh!!!! moment for the week.
Sign In or Register to comment.