CodeIgniter Forums
Organizing Controllers into Subfolders - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: Organizing Controllers into Subfolders (/thread-46622.html)



Organizing Controllers into Subfolders - El Forum - 11-08-2011

[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!