Advanced module: routing, structure: How?
Hi!
I started to buld website using Fuel CMS.
I am create advanced module named Charters and want create admin backend for this module and user front-end.
I was generated advanced module using Fuel CMS generaton. Generator created module structure, and I want to extend it.
My config:
$config['nav']['charters'] = array(
'charters/' => 'Charters',
'charters/airports' => 'Airports',
'charters/aircrafts' => 'Aircrafts',
);
$route[FUEL_ROUTE.'charters'] = 'charters';
refers to a controller charters_module.php - in nav 'charters/' => 'Charters'
I need create submodules for 'charters/airports' => 'Airports', etc. Does any my modules must ends with _module.php ?
How to define routing for another controller using nav structure? 'charters/airports' => 'Airports' works just if I have airports() method in charters controller, but I want airports standalone controller for add, edit, delete airports.
And for backend I need to use Fuel_base_controller for controllers, but I can use CI_Controller for front-end?
Comments
https://github.com/daylightstudio/FUEL-CMS-Blog-Module/tree/develop
Note that there is a config/blog_routes.php file which creates the routes for the Posts, Comments, etc simple modules. In addition, there is a config/blog_fuel_modules.php file used to setup the module.
And yes, Fuel_base_controller or a controller extending that, should be used for backend controllers because it has authentication and rendering methods using the Fuel_admin class.
Blog module is very useful. I study the advanced modules using this module.
I just had a little hitch with routing.
And now all works fine.
//for backend Fuel_base_controller $route[FUEL_ROUTE.'charters/aircrafts'] = CHARTERS_FOLDER.'/charters_aircrafts'; $route[FUEL_ROUTE.'charters/aircrafts/(.*)'] = CHARTERS_FOLDER.'/charters_aircrafts/$1 .... // Front-end public controller CI_Controller $route['service'] = CHARTERS_FOLDER.'/charters_service'; $route['service/(.*)'] = CHARTERS_FOLDER.'/charters_service/$1'; ....
The other thing I'm want to CRUD with buttons bar on top and search, reset, limit form like on blog or pages module.
As I understand I can use for this purposes blocks from fuel/view/_blocks: module_list_table.php, module_create_edit_actions.php and module_list_actions.php - this blocks will works only if in my controllers exists methond like 'save', etc. I found check for module action in $this->fuel->auth->module_has_action('save') if my controller have method 'save', save button will be visible?
Or better create own new blocks with buttons bar, table for CRUD?
http://docs.getfuelcms.com/libraries/fuel_admin
To have the save button appear, you'll need to have an item_actions parameter specified on your simple module that includes "save" which they all do by default unless overwritten:
http://docs.getfuelcms.com/modules/simple
The module parameters get transferred as properties of the $CI object which is the module controller so it can be access in the Fuel_auth::module_has_action method as $this->CI->item_actions.
This trick just for simple modules or I can use it with advanced modules?
My admin module controllers extends Fuel_base_controller and Fuel_base_controller extendsF uel_admin, so this trick must work?
I understand!
This admin CRUD is created automatically from my model (extends Base_module_model)! I don't need use controllers to create admin CRUD. It's cool!
My table have several foreign keys. Problem is I need use join to one table twice.
I use list_items method in my model
Two fields: departure and destination is foreign keys to airports table.
I use:
$this->db->join('airports', 'airports.id = routes.departure_airport', 'left'); // for departure
But I need the same for destination point. If I use the same code - gets Database Error.
Needs to add an alias for join
$this->db->join('airports dep', 'dep.id = routes.departure_airport', 'left');
and use dep.id inthread of airports.id
I noticed that for INT field created input type="number" max="10" for any integer length.
Is it bug or I need redefine this default value?
function form_fields($values = array(), $related_values = array()) { $fields = parent::form_fields($values, $related_values); $fields['my_field_name']['max'] = {yourvalue}; .... return $fields; }
Thanks, It works for me.