Welcome Guest, Not a member yet? Register   Sign In
Organizing Controllers into Subfolders
#1

[eluser]Unknown[/eluser]
I'm building a site using CodeIgniter and up until now things have been going great. However, recently one of my controllers has been growing in size. I'd like to split the controller up into separate files within a sub-folder. Right now I have the following....

Code:
/controllers/dashboard.php

Within that controller I have a functions for all the different sections. So, the URL might be something like this...

/dashboard/pages/add

I know I can setup a subfolder and have my URL be like the following....

/dashboard/staff/pages/add
/dashboard/user/profile

But, I'd like to omit the 'usergroup' if at all possible. I'd like to do this by the following....

Code:
/controllers/dashboard/ -> If staff load staff.php, if user load user.php...etc.

This would be so much easier if I could just go....

Code:
$this->load->controller();

How would you suggest I setup a dashboard area? Each usergroup has different things they need to access. Putting everything in one document is getting too long, and separating them out means I have to put the usergroup in the URL....yucky.

Is it possible to run a check in routes.php?

Code:
if ($this->user_model->is_user()) {
  // load this controller
}

Hope you guys have some suggestions for me!




Theme © iAndrew 2016 - Forum software by © MyBB