0

I need to create sub folders for my controllers for ease of managing and troubleshooting. I need to have controller/, controller/admin, controller/user/ kind of setup. I have tried creating the controller in controller/admin/createuser from http://mydomain/admin/createuser but that does not seem to work.

Anyone with tips on this?

Do I need custom routing?

Churchill
  • 1,587
  • 5
  • 27
  • 39

1 Answers1

1

You would need to set up a Route to catch /admin/ and look for an 'directory' called admin rather than a 'controller file' called admin. Then your 'createuser' param would ideally be in a 'user' controller, so 'createuser' would be an action in your users controller


Note the 'directory' declaration - application/bootstrap.php

Route::set('admin', 'admin(/<controller>(/<action>(/<id>)))')
  ->defaults(array(
    'directory' => 'admin',
    'controller' => 'user',
    'action' => 'index',
));

Then in your controller you need to use underscores for each directory '/' in the Class name - application/classes/controller/admin/user.php

class Controller_Admin_User extends Controller {

  public function action_createuser()
  {
    ..your code
  }
mdskinner
  • 498
  • 4
  • 12
  • Thanks a lot. How can I have some sort of SEF urls with this? – Churchill Jul 29 '11 at 11:39
  • You can use any urls you want with Routes.. just take out the or what ever, and then tell it what controller you want the specified path to use: Route::set('loggingIn', 'admin/login')->defaults('controller'=>'user', 'action'=>'login') they are cascading, so put one like this higher up in page and it will be caught first if the path matches. – mdskinner Aug 01 '11 at 02:11
  • This works. Guaranteed, the 'id' parameter is required. Could you make your route code solution where 'id' would be optional? I take out the (/) or add array('id' => '.*') as a third parameter for Route::set() but it doesn't work. – jagc Sep 16 '15 at 02:22