CodeIgniter Forums
Admin CP and Sub-Directory - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: Admin CP and Sub-Directory (/showthread.php?tid=62077)



Admin CP and Sub-Directory - StratoKyke - 06-07-2015

At the second point in this guide https://philsturgeon.uk/blog/2009/07/Create-an-Admin-panel-with-CodeIgniter/ talks about the sub-directory for create an admin cp and the routers.
But my question is: How create a general route for every controller that I create in the sub-directory "admin" for example?

And when I write $route[‘admin’] = ‘admin/dashboard’; codeigniter should not look for the controller "admin" with the method "Dashboard"?

Sorry for the questions, I have probably done a bit of confusion.
Could you explain how to create an admin cp using subdirectories?

Thanks for the reply.


RE: Admin CP and Sub-Directory - Diederik - 06-07-2015

You dont need any routes for this, CI will work out of the box. CI automaticly detects a folder like 'admin' with one or more controllerfiles (like Login.php) in it and adds a internal route for site.com/admin/login. Atleast At the top of my head I cant recall modifing the routes manual for this.

Please mind that the tutorial is from 2009(!), a few things have chenged since then, one for example wich could explain your issue is that controller files now should start with a capital character, try renameing your file to admin/Dashboard.php and check the upgrade documentation for other changes that might effect you if you try examples from so long ago.


RE: Admin CP and Sub-Directory - Blair2004 - 06-07-2015

I'M not sure about what diedErik says... I not saying that it's false. But for me I'M using admin.pop file to handle admin cp. You can check how it's done here https://github.com/Blair2004/tendoo-cms/blob/1.5-auth-feature/application/controllers/Dashboard.php


RE: Admin CP and Sub-Directory - Avenirer - 06-08-2015

What @Diederik said. Especially the part with the 2009... Also, in order to make some publicity for my site Big Grin , you could try my tutorials: http://avenir.ro/create-cms-using-codeigniter-3/create-admin-area/


RE: Admin CP and Sub-Directory - StratoKyke - 06-08-2015

(06-08-2015, 02:02 AM)Avenirer Wrote: What @Diederik said. Especially the part with the 2009... Also, in order to make some publicity for my site Big Grin , you could try my tutorials: http://avenir.ro/create-cms-using-codeigniter-3/create-admin-area/

Thanks for all reply Smile

I follow Avenirer's guide. And I read the Step 1. I wonder, I'll have to specify the routes for each controller? Or is there a way to automate the process as it normally should be?


RE: Admin CP and Sub-Directory - Avenirer - 06-08-2015

Not really, as this is only a sort of elegant way to "redirect" someone who simply introduces 'admin' in the url. After that you will do all anchors to where you need to send people.


RE: Admin CP and Sub-Directory - StratoKyke - 06-08-2015

Maybe we have not understood Big Grin
When you go to create a controller normally, this is automatically read by codeigniter.

This is done even now? Or should I always specify that the controller x equals the routes x?


RE: Admin CP and Sub-Directory - Blair2004 - 06-08-2015

that's the default behavior. But if you want this url "http://site.com/admin" open application/controllers/dashboard.php instead, you should mention it on routes config file.


RE: Admin CP and Sub-Directory - StratoKyke - 06-08-2015

Yeah Smile Thanks for the support and reply.


RE: Admin CP and Sub-Directory - CroNiX - 06-08-2015

When using a subdir for a controller, I usually just need to add ONE route, and that's to go to a controller if someone only went to the dir (/admin) without supplying a controller.

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