Welcome Guest, Not a member yet? Register   Sign In
CI 2: Routing for admin/dashboard and general user
#1

[eluser]Unknown[/eluser]
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

mydomain.com/admin/membership/users

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?

Thx,

Tac
#2

[eluser]kreamik[/eluser]
i'm noob in php,
but could you use mapping function in CI?
#3

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

MY_Controller.php
Code:
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:
Code:
class Home_page extends Public_controller {

}

// or

class Admin_home extends Admin_controller {

}




Theme © iAndrew 2016 - Forum software by © MyBB