Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

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.

share|improve this question
    
@Broncha - could you explain a little further how this works? I'm particularly interested around the Content_controller.php for both front end and backend usage. What does your config/routes.php file look like and what are the basic setup for the front end / backend Content_controller.php files. Thanks in advance –  user92869 Jun 3 '13 at 9:25
add comment

1 Answer

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. :)

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.