Help with advanced module

edited December 2012 in News & Announcements

Following the toturial on advanced module, I am trying to create a module for admin.

I've created all the files, I see the admin toolbar, but when I click on the open orders link I get this error:

A PHP Error was encountered
Severity: Notice
Message: Undefined property: Module::$model_name
Filename: controllers/module.php
Line Number: 79
An Error Was Encountered

Unable to locate the file: .php

My openorders controller begins with:
<?php require_once(FUEL_PATH.'/libraries/Fuel_base_controller.php');

class Openorders extends Fuel_base_controller {
public function __construct()


I tried that as well:
<?php require(MODULES_PATH.'/module.php');

class Openorders extends Module {
public function __construct()


Not sure what I am doing wrong, didn't really understand that part in the tutorial:
"3. Create your controller files.
Admin Controllers - Pages that need to be displayed in the admin interface should inherit from the fuel/modules/fuel/libraries/Fuel_base_controller.php OR fuel/modules/fuel/controllers/module.php (which inherits from Fuel_base_controller) and can use the _validate_user(), protected controller method."

and I think the problem might be there.

Can you please help?


  • edited 7:01PM
    That error message most likely appears because it is looking for a simple module named "openorders". Do you have one defined in your MY_fuel_modules.php file?
  • edited 7:01PM
    Hi admin,

    I used to have an openorders simple module but I deleted the line from MY_fuel_modules. Do I need to delete anything anywhere else?
  • edited 7:01PM
    You need to add it in order for that error message to go away. You can create it in your advanced module with a config file of "openorders_fuel_module.php" with the same info in it (FUEL automatically looks for those files in advanced modules).
  • edited 7:01PM
    Ok, I am more confused now.

    Maybe I should explain what I want:

    I need to have a title called Admin on the dashboard, under it I will have two links:
    Open Orders
    Closed Orders

    I have a database table called orders. In the Open Orders I want to display only open orders from this table and of course in the Closed Orders only closed ones.

    I have created an advanced module called admin.

    It has a config file with this code:
    $config['nav']['admin'] = array( 'admin/openorders' => 'Open Orders', 'admin/closedorders' => 'Closed Orders', );

    admin_constants file:
    define('ADMIN_VERSION', '1.0.0'); define('ADMIN_FOLDER', 'admin'); define('ADMIN_PATH', MODULES_PATH.ADMIN_FOLDER.'/');

    $admin_controllers = array('openorders', 'closedorders'); foreach($admin_controllers as $c) { $route[FUEL_ROUTE.'admin/'.$c] = FUEL_FOLDER.'/module'; $route[FUEL_ROUTE.'admin/'.$c.'/(.*)'] = FUEL_FOLDER.'/module/$1'; }

    I have openorders controller.

    What do I put in this controller?
    Do I start it like this?
    <?php require_once(FUEL_PATH.'/libraries/Fuel_base_controller.php'); class Openorders extends Fuel_base_controller { public function __construct() { parent::__construct(); $this->load->model('admin_model'); }

  • edited 7:01PM
    Try creating a fuel/modules/admin/config/admin_fuel_modules.php" file which has the following:
    // add additional module config parameters here $config['modules']['openorders'] = array(); $config['modules']['closedorders'] = array();
    The advanced module still needs to define the simple modules within it.
  • edited 7:01PM
    Ah, that makes things clearer :)

    Now another question, can I create a simple module called openorders when I don't have an openorders table?
  • edited 7:01PM
    You can, but you must implement a few methods on the model (e.g. add_filters, list_items, list_items_total, find_by_key, record_count, delete, key_field, get_validation, get_errors, form_fields). The assets_model does this in which it uses the file system essentially as it's data source and inherits from the generic CI model instead of the base_module_model. Do you have another table that it needs to reference?
  • edited 7:01PM
    Wow, thank you for such fast replies.
    Yes the module will need to refference a few tables.

    Is there a way I can use the controllers and models I have developped for this in my codeigniter site instead of redeveloping everything?
  • edited 7:01PM
    Regarding using the same controllers and models, it's tough to say. I would hope you could use at least the models perhaps by augmenting them to support those methods. The controller for it to work inside the CMS would need to extend the Fuel_base_controller and you'd probably want to add certain permissions to validate against for the module. You could extract the reusable parts of the controller into a separate shared library they could both use.
  • edited 7:01PM
    Where do I find the assets_model?

    Merry Christmas
  • edited 7:01PM
    Merry Christmas to you as well. The file can be found in the fuel/modules/fuel/models/ folder.
Sign In or Register to comment.