CodeIgniter Forums
best practice to setup admin controller? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: best practice to setup admin controller? (/showthread.php?tid=48876)



best practice to setup admin controller? - El Forum - 01-31-2012

[eluser]snoo[/eluser]
Hello guys,

I'm setting up my admin controller and is a little bit confused on how to structure my files.

I want my url to be as such:

blog entries: /admin/blogs
static page: /admin/pages
menu: /admin/menu
etc

Am I limited to putting all my page controls into my admin class as functions? Or is it possible to actually make a blog controller, or a static page controller, in admin folder, inside my controller?

thanks much for any pointer.


best practice to setup admin controller? - El Forum - 01-31-2012

[eluser]CroNiX[/eluser]
Yes, create a folder in /application/controllers, like /application/controllers/admin
Put all of your admin controllers in there.
create a default route, so if they enter /admin (which is just a folder) it will take them to a specific controller. This would normally be a dashboard or something.

Code:
$route['admin'] = 'admin/controller/method';

I would also look into base classes, so you can create an admin_controller, which does things like check for auth, etc. Then all other admin controllers would extend the Admin_controller instead of CI_Controller.

Here's a good article to read on that.


best practice to setup admin controller? - El Forum - 01-31-2012

[eluser]snoo[/eluser]
great! I will give that a try. thank you very much.


best practice to setup admin controller? - El Forum - 01-31-2012

[eluser]vbsaltydog[/eluser]
You should have your admin controllers extend MY_Controller and put your authentication in MY_Controller so you can keep your code DRY.