Add a sub action to a simple module

edited February 2015 in News & Announcements
Hi there,

I've created a simple module:

In the file "config/MY_fuel_modules.php", we've got:

$config['modules']['example'] = array(
'preview_path' => 'example/{slug}',
'sanitize_images' => FALSE, // to prevent false positives with xss_clean image sanitation
'list_actions' => array('example/upload' => lang('btn_upload')),

This has added a new action button called "upload".

When we visit "/fuel/example/upload" you get a frontend 404 error page.

Is there a simple way to make our simple module "example_model.php" handle sub actions?



  • edited 5:46AM
    You'll need to create a controller that extends the module controller and create a route for it (potentially). The pages.php and navigation.php controllers in the fuel/modules/fuel/controllers/ folder do this. You can place this controller in your fuel/application/controllers/ folder.
  • edited 5:46AM
    I just installed fuel and create a module.
    I have same problem with sample "project module".
    I have to copy navigation.php and pages.php to my application controller? with change or not change.
    please explain me more
  • edited 5:46AM
    Basically, you can approach it like you would a normal CodeIgniter site where you need to create a controller that can perform the upload action you need. You can create this in your main fuel/application folder. I mentioned the pages and navigation controllers because they do something similar and can be used as an example. They extend the module.php controller. You'll also want to create a route for fuel/example/upload in your routes.php file.
  • edited March 2015
    in another words, I want to use user module for make my new module.
    for example I create example module with preview_path=> 'example/id/x'
    But I got 404 page not found. I made a controller and its action in my application but didn't change response.
    In where clause I wana get id from segment and put it on my function list_items.
    thanks for your answer

    like projects/{slug} in your 3th tutorial, I create function get_url() and
    return site_url('projects/id/' . $this->id);
  • edited 5:46AM
    This documentation seems to be maybe what you are looking for:
  • edited 5:46AM
    I solved my problem with a simple solution:
    I had 2 changes:
    1- Add line 482 fuel/controllers/module.php
    $this->js_controller_params['item_id'] = $this->uri->segment(4);
    2- Edit line 16 fuel/assets/js/fuel/controller/BaseFuelController.js
    this.tableAjaxURL = this.modulePath + '/items/'+initObj.item_id;

    this is very simple way to get segment for all module.
    I had some other changes for edit and create to work probably.

    you can prepare this for next version of Fuel.
Sign In or Register to comment.