2
votes

I am having some trouble coming up with the routes for the following scenario...

I have a module controller in say...

/modules/mymodule/classes/controller/mymodule.php (class Controller_Mymodule) and the url being

/mymodule/

and then I want to have the admin controller /modules/mymodule/classes/controller/admin/mymodule.php (class Controller_Admin_Mymodule)

but the url would be

/admin/mymodule/

I am trying this route below but I am getting the error: Unable to find a route to match the URI: admin

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

1 Answers

1
votes

Unable to find a route to match the URI: admin

Does it mean that admin/mymodule works? Anyway, admin will failed because your route has required controller param. Here is the same route with optional controller segment:

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

PS. You can skip action param because 'index' is a default value.