![]() |
Admin controller - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: Admin controller (/showthread.php?tid=13960) Pages:
1
2
|
Admin controller - El Forum - 12-13-2008 [eluser]Unknown[/eluser] Hi all! How can I put my admin controllers into ../controllers/admin/controlle_name.php and access them via mysite.com/admin/controller_name/method ??? Does I need to write my own route file or other way??? Thanks! Admin controller - El Forum - 12-13-2008 [eluser]healer[/eluser] hi, look in user guide http://ellislab.com/codeigniter/user-guide/general/controllers.html#subfolders section. You can put your controller ../controllers/admin/controlle_name.php and you must add new route to your routes.php file like this one $route['admin'] = 'admin/controller_name'; this is your default controller for admin section. You dont need to add routes for each controller in admin folder. just add for default one. Admin controller - El Forum - 12-13-2008 [eluser]Unknown[/eluser] Thanks! The problem was solved! I need to use folder "../modules/admin/controllers/controller_name.php", then I use Modules extension. Admin controller - El Forum - 12-13-2008 [eluser]mamen[/eluser] Waw Thank's that's Very helpfull Thank's healer Admin controller - El Forum - 12-13-2008 [eluser]OwanH[/eluser] Hi Cyrill, Also note what the user guide says @ http://ellislab.com/codeigniter/user-guide/general/controllers.html#subfolders. You can create sub-folders within the application/controllers directory and place your controller classes within them. So... you can create an admin sub-folder in application/controllers and place your admin controllers in there. Admin controller - El Forum - 12-20-2008 [eluser]ntheorist[/eluser] Hey i'm working on a similar problem. I understand building a subfolder in the controllers folder well enough, but is there a way to simulaneously have each controller in the 'admin' subfolder, extend an admin_controller file, which is itself an extend of controller, so you could add in whatever admin/security functions necessary.. ie Code: class Admin_Controller extends Controller Code: if ( ! defined('BASEPATH')) exit('No direct script access allowed'); thx cc Admin controller - El Forum - 12-21-2008 [eluser]OwanH[/eluser] Hey commandercool, I would actually recommend that you continue to do what you've already tried, i.e. add a require_once at the top of all the admin controllers. As you've noticed the Autoload wouldn't work and neither would the hooks feature. Admin controller - El Forum - 12-29-2008 [eluser]simshaun[/eluser] Thanks for that code commandercool. I was wondering how I'd go about doing that. Admin controller - El Forum - 12-30-2008 [eluser]xwero[/eluser] I have some issues with Extending controllers because of the inflexibility, you can only extend a class from one parent class. So i use hooks most of the time and because you store the controllers in a subfolder it can be used as a trigger. Code: function init() Code: class Home extends Controller Admin controller - El Forum - 12-30-2008 [eluser]Phil Sturgeon[/eluser] I answered a similar question about admin controllers in another post Auto including data in my view and as for the layout of your admin files, put one admin.php controller (extended from Admin_controller of course) in each module, then chuck the following routes in like on the post "matchbox and that old admin folder question". Quote:$route['admin/([a-z]+)/(:any)'] = "$1/admin/$2"; |