Advanced module.

edited August 2011 in Modules
Could you please put an easy example of making an advanced module? I'm stuck to this ...
Print screens of my module are here:
http://xs.to/media/86563

Comments

  • edited 11:51AM
    What kind of problem are you needing resolution with? (e.g. viewing it in the CMS admin, viewing the pages on the front-end etc...)
  • edited August 2011
    I got 404 when i try to go to fuel/anunturi/rent_categories
  • edited 11:51AM
    Have you setup a route for that in your config/anunturi_routes.php file (I couldn't see in the image)? You'll want to do a route something like this:
    $route[FUEL_ROUTE.'anunturi/rent_categories'] = ANUNTURI_FOLDER.'/module'; $route[FUEL_ROUTE.'anunturi/anunturi/rent_categories/(.*)'] = ANUNTURI_FOLDER.'/module/$1';
  • edited 11:51AM
    yes. I did :(
  • edited 11:51AM
    I also corrected the misspelling "s" after constant in anunturi_constant.php.
  • edited 11:51AM
    I guess it should be like this:
    $route[FUEL_ROUTE.'anunturi/rent_categories'] = FUEL_FOLDER.'/module';
    $route[FUEL_ROUTE.'anunturi/anunturi/rent_categories/(.*)'] = FUEL_FOLDER.'/module/$1';
  • edited 11:51AM
    Oops... yes, that is correct. It should be FUEL_FOLDER instead of ANUNTURI_FOLDER (assuming that that is where you are wanting to route things which is most likely).
  • edited 11:51AM
    It still doesnt work.. now I got this

    A PHP Error was encountered Severity: Notice Message: Undefined property: Module::$model_name Filename: controllers/module.php Line Number: 79 A PHP Error was encountered Severity: Warning Message: Cannot modify header information - headers already sent by (output started at /public_html/codeigniter_stuff/fuel/fuel/codeigniter/core/Exceptions.php:170) Filename: core/Common.php Line Number: 414 An Error Was Encountered Unable to locate the file: .php
  • edited August 2011
    this is my model :
    <?php if (!defined('BASEPATH')) exit('No direct script access allowed'); require_once(FUEL_PATH.'models/base_module_model.php'); class Rent_model extends Base_module_model { public $record_class = 'Rent_category'; function __construct() { parent::__construct('sa_rent_categories', ANUNTURI_FOLDER); // table name } function list_items($limit = NULL, $offset = NULL, $col = 'name', $order = 'desc') { $this->db->select('id, name, slug, published'); $data = parent::list_items($limit, $offset, $col, $order); return $data; } function _common_query() { parent::_common_query(); // to do active and published $this->db->order_by('name desc'); } function form_fields($values = array()) { $fields = parent::form_fields(); $CI =& get_instance(); $fields['slug'] = array('label' => 'Slug'); return $fields; } } class Rent_category_model extends Base_module_record { function get_url() { if (!empty($this->slug)) return "inchirieri/".$this->slug; return site_url('inchirieri/'.$this->id); } } ?>
  • edited August 2011
    and this is my controller

    <?php require_once(FUEL_PATH.'/libraries/Fuel_base_controller.php'); class Rent extends Fuel_base_controller { public $nav_selected = 'anunturi/rent'; public $view_location = 'rent'; function __construct() { parent::__construct(); $this->load->module_model(ANUNTURI_FOLDER, 'rent_model'); } function index() { echo "test"; } } /* End of file rent.php */ /* Location: ./fuel/modules/anunturi/controllers/rent.php */
  • edited August 2011
    If I go to.. front end and type anunturi/rent i see the "test" . The error I got when I try to go to fuel/anunturi/rent in backend.

    P.S. I removed the word 'categories' from all the names of my files from the printscreen
  • edited 11:51AM
    What do you have in your config/anunturi_fuel_modules.php file?
  • edited 11:51AM
    Just this:
    <?php $config['modules']['rent'] = array( 'module_name' => 'Rent', 'module_uri' => 'anunturi/rent', 'model_name' => 'rent_model', 'model_location' => 'anunturi', 'table_headers' => array( 'id', 'name', 'slug', 'published', ), 'nav_selected' => 'anunturi/rent', );
  • edited 11:51AM
    Would you mind emailing me those module files and any SQL. I'm not able to immediately see the issue? My email address is under my profile if you click on the my image.
  • edited 11:51AM
    Actually, the second route should be:
    $route[FUEL_ROUTE.'anunturi/rent_categories/(.*)'] = FUEL_FOLDER.'/module/$1'

    See if that helps.
  • edited 11:51AM
    Name the module key "anunturi_rent" instead of "rent" like so:
    <?php $config['modules']['anunturi_rent'] = array( 'module_name' => 'Rent', 'module_uri' => 'anunturi/rent', 'model_name' => 'rent_model', 'model_location' => 'anunturi', 'table_headers' => array( 'id', 'name', 'slug', 'published', ), 'nav_selected' => 'anunturi/rent', );

    The reason is because FUEL looks at the URI path to determine which module configuration to pull in, and when you are using an advanced module, it needs to be prefixed like that. Not obvious I know.
  • edited 11:51AM
    yeeeeee :) It`s working. Thank you for that. Probably I`ll have some more questions, but for now...I can go on with understanding fuel and testing what I`ve learned.
Sign In or Register to comment.