Kohana 3.2 Route - controllers in subdirectories

2019-09-07 03:18发布

问题:

I need to create next structure:


    +controller
      ++admin
       +++catalog
        ++++category.php
        ++++product.php
       +++users

and I need to open them by url /admin/catalog/category/action/param I tried to create route:

 Route::set('admin', '(<directory>(/<controller>(/<action>(/<custom_param>))))',array(
        'directory' => '(admin/.*)'
    ))
    ->defaults(array(
        'controller'  => 'dashboard',
        'action'        => 'index'
    ));

回答1:

Not tested:

Route::set('admin', 'admin/<directory>/(<controller>(/<action>(/<custom_param>)))',
    array(
        'directory' => '(catalog|users)'
    ))
    ->defaults(array(
        'controller' => 'dashboard',
        'action'     => 'index',
    ));