I have been having problems wrapping my brain around how to properly utilize the modular extension for Codeigniter. From what I understand, modules should be entirely independent of one another so I can work on one module and not have to worry about what module my teammate is working on. I am building a frontend and a backend to my site, and am having confusion about how I should structure my applications.
The first part of my question is should I use the app root controllers to run modules, or should users go directly to the modules by urls?
IE: in my welcome.php
public function index()
{
$this->data['blog'] = Modules::run( 'blog' );
$this->data['main'] = Modules::run( 'random_image' );
$this->load->view('v_template', $this->data);
}
public function calendar()
{
$this->data['blog'] = Modules::run( 'blog' );
$this->data['main'] = Modules::run( 'calendar' );
$this->load->view('v_template', $this->data);
}
My second part of the question is should I create separate front/back end module folders
-config
-controllers
welcome.php
-admin
admin.php
-core
-helpers
-hooks
-language
-libraries
-models
-modules-back
-dashboard
-logged_in
-login
-register
-upload_images
-delete_images
-modules-front
-blog
-calendar
-random_image
-search
-views
v_template.php
-admin
av_template.php
Any help would be greatly appreciated.
1
Just sharing what I do.
I let the users directly access the module.
I have separate controllers for both backend and frontend for the module within the module.
All the backend controllers extend Admin_Controller and frontend controller extend Front_Controller.
The admin page is rendered by the module itself (there is a master template for the admin area/front area and the module fills the main working area in the template).
All the requests are handled by the modules itself.
This way both backend and frontend are solely handled by the module itself.
My folder structure is slightly different than yours:
+application
|--+modules
|--+content
|--+controllers
| |--+admin
| |--Content_Controller.php (This handles the backend requests)
| |--Content_Controller.php (This handles the frontend requests)
|--models
|--+views
| |--+admin (this contains the views for backend)
| |--+front (this contains views for front end)
So if you need to remove the content module just remove the folder from the modules directory. 🙂