How to tell Fuel where to look for a model file when creating a Simple Module
I am attempting to hook up a model file that directly maps to a single database table called "subscription_types". The simple module tutorial instructs that the "subscription_types_model.php" file be placed in /fuel/application/models, but I want to know how to get this module to show up in the Fuel Admin if I were to place this file in this location:
/fuel/modules/corporate_partners/models
Right now I get an error saying "Unable to locate the file: subscription_types_model.php" so I'm wondering how would I wire this up from this location and is it possible?
Thanks,
Erik
Comments
Also, add "corporate_partners" to your "allowed_modules" configuration parameter in MY_fuel.php
Here is my corporate_partners_fuel_modules.php file:
$config['modules']['corporate_partners'] = array( 'module_name' => 'Corporate Partners', 'module_uri' => 'corporate_partners', 'model_name' => 'corporate_partners_model', 'model_location' => 'corporate_partners', 'table_headers' => array( 'id', 'name', 'key', 'password', 'subscription_type_id', 'contact_name', 'contact_email' ), 'display_field' => 'name', 'permission' => 'corporate_partners', 'instructions' => lang('module_instructions_default', 'corporate partners'), 'archivable' => FALSE, 'nav_selected' => 'corporate_partners', ); $config['modules']['subscription_types'] = array( 'module_name' => 'Subscription Types', 'module_uri' => 'corporate_partners/subscription_types', 'model_name' => 'subscription_types_model', 'model_location' => 'corporate_partners', 'table_headers' => array( 'id', 'name', 'cost_per_subscriber', 'subscriber_cost', 'type' ), 'display_field' => 'name', 'permission' => 'corporate_partners', 'instructions' => lang('module_instructions_default', 'subscription types'), 'archivable' => FALSE, 'nav_selected' => 'subscription_types', );
I have added this code to my config/corporate_partners.php file (for the left-hand navigation):
$config['nav']['corporate_portal'] = array( 'corporate_partners' => 'Corporate Partners', 'corporate_partners/subscription_types' => 'Subscription Types', );
What am I doing wrong if it gives me a 404 when accessing /fuel/corporate_partners/subscription_types?
<?php if (!defined('BASEPATH')) exit('No direct script access allowed'); require_once(FUEL_PATH.'models/base_module_model.php'); class Subscription_types_model extends Base_module_model { function __construct() { parent::__construct('subscription_types'); } } class Subscription_type_model extends Base_module_record { }
My end goal in all of this is to have an umbrella module called "corporate_partners" that resides at fuel/modules/corporate_partners and to also have 2 sub-modules, one also called "corporate_partners" that has a model file that directly maps to the corporate_partners table and a module called "subscription_types" whose model maps to the subscription_types table. I would like to be able to edit the data in both of these tables via the Fuel interface.
Let me know if I've thought this through correctly based on the design of the module feature of Fuel.
$config['modules']['subscription_types'] = array( 'module_name' => 'Subscription Types', 'module_uri' => 'subscription_types', 'model_name' => 'subscription_types_model', 'model_location' => 'corporate_partners', 'display_field' => 'name', 'permission' => 'subscription_types', 'instructions' => lang('module_instructions_default', 'subscription types'), 'archivable' => FALSE, 'nav_selected' => 'subscription_types' );
That got it to work finally .
So here's my next question. I liked how I was able to customely define the Fuel navigation for the Corporate Partners module. The change I made above to the MY_fuel_modules file however, exposes the "Modules" option on the left hand side. I would like that to go away and instead have a custom navigation that I have defined in the config/corporate_partners.php file which changes the word "Modules" in the left-hand side to say "Corporate Partners".
I am able to expose this custom menu if I define the navigation structure for the menu in config/corporate_partners.php AND allow the corporate_partners module in MY_fuel.php. So the thing I would like to know is how do I hide the "Modules" menu from the Fuel navigation?