Note the upgraded forum! If you are experiencing issues logging in, you may need to reset your password which should send an email. If the email doesn't arrive, be sure to check your spam folder just in case.

simple modules!

edited November 2011 in Modules
The way - we create simple modules--> awesome.
Now - If I want to over ride the CRUD functionality behind CREATE/UPDATE/SELECT/DELETE, I need to define a controller for the model and just over ride respective methods?
for example : while creation of record - I also want to call a webservice - Can I accomplish by overriding a create method in controller?
Where do I over ride the views create view, edit, delete view, listing. Basically - I might need aditional buttons on the view screens.

Please let me know if Advanced modules is the way to go. The issue I have is -- I like the views as is - just need additional functionality around controller and views.

thanks
sid

Comments

  • edited 7:58PM
    You can create your own controller to use instead of the default "module" controller like you said. The pages and navigation controller do this (in fuel/modules/fuel/controllers/). The views can be configured by the simple modules "views" parameter which by default is set to:
    ... 'views' => array( 'list' => '_layouts/module_list', 'create_edit' => '_layouts/module_create_edit', 'delete' => '_layouts/module_delete'), ...
    You can also set the a "view_location" property on your controller, which tells FUEL which module folder to look in for the view files.

    Additionally, there are "list_actions" and "item_action" simple module properties that can use to to add additional buttons. Below is an example of a list_actions module parameter used by the navigation module to add the upload button:
    'list_actions' => array('navigation/upload' => lang('btn_upload'))
    Item actions appear in the form view and specify which buttons to appear at the top. Below is an example used by the pages module and note the 'others' key value which contains the custom upload button:
    'item_actions' => array('save', 'view', 'publish', 'delete', 'duplicate', 'create', 'others' => array('pages/upload' => lang('btn_upload'))),
    http://www.getfuelcms.com/user_guide/modules/simple
  • edited 7:58PM
    Thanks.
    But when I try to call the model in the controller - I get model and method undefined.
    Seems like the controller is not getting the model.
    Do I need to load it somewhere?
  • edited 7:58PM
    The module uses the URI segment to grab the initialization parameters for a module (see line 16-31 or so of the fuel/modules/fuel/controller/module.php). I'd recommend creating a route to map to a uri like "fuel/my_module".
  • edited 7:58PM
    You are referring to advanced module where in you provide model_location.
    However, I am trying to just have a controller in the controller folder. I have a model in models folder (Simple Modules)
    Then in control, I am trying to access model like
    $this->model->getSysConfig($user_id);

    in My_fuel_modules - i have added the url --> 'my_controller/my_method'
    The link shows on the dashboard and program control goes to "my_method" method.
  • edited 7:58PM
    Is your controller inheriting from the fuel/modules/fuel/controller/module.php controller? If so, can you test the controller property of "module_name" by doing the following in your controller method?
    print_r($this->model_name);
  • edited 7:58PM
    Ok - I was extending from Fuel_base_controller. Now I get access to model when I extend from Module.

    Thanks a lot --> this should work now.
Sign In or Register to comment.