CI 2: Routing for admin/dashboard and general user

I'm trying to figure out the best way to handle routing for an application that has an admin UI and a regular user UI. I'm sure this has been handled somewhere before, I'm hoping someone can point me to the right way to configure this.

I tried creating different application directories, but there are too many things that are shared -- the library, the model classes, etc. I think what I want to do is just have my admin controllers in their own directory, so that

would use the Membership class in controllers/admin and call the 'users' method, but I'm not convinced that this is the only or the best way. Even so, I'm not sure how to configuring the routing so that this work.

Any suggestions?



i'm noob in php,
but could you use mapping function in CI?

Take a look at creating a base controller class, i use this approach for smallish admin / user sites.

class MY_Controller extends Controller {
// shared stuff

class Admin_controller extends MY_Controller {
// admin specific stuff

class Public_controller extends MY_Controller {
// public user stuff

I find this easier to do authentication in the base controller.
Arrange your controllers how you want in your directories and just call them:
class Home_page extends Public_controller {


// or

class Admin_home extends Admin_controller {


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.