0

I'm a beginner to MVC and trying to figure this out. More of a hobbyist than anything else but I'm trying to learn!

I'm trying to create an admin area that contains multiple areas within. Shop, Blog, Social, etc.

The directory layout I'm using is:

Controller [folder]
-Admin [folder]
--area name, ie Shop/Blog/Social [folder]
--- Index.php (controller for that area)

I'm using this routing for the Shop:

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

That loads Controller/Admin/Shop/Index.php: Class Controller_Admin_Shop_Index extends Controller {}. This all works fine which is awesome!

What I want to do in the end is to create a single Admin area: /admin/ that will load other sections as they're navigated to.

That's where I'm getting stuck and not sure where to go.

I'd like to be able to view url.com/admin/ and in there would be tabs to different areas. That would load url.com/admin/shop/ or url.com/admin/social/

Can I need to create a catch all route for each directory?

My attempt that fails:

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

Or do I need to create a route for all the possible areas instead of putting ?

The app flow would load admin/index and then from that controller I would like to be able to load/display the other sections through internal requests. Am I going about this all wrong? I'm trying to compartmentalize each area so that if I need to change social in the future I wouldn't have to touch any of the other admin areas or as least amount of files outside the section I'm changing.

Sorry for the long post and Thank you for any help you can provide!

jim brown
  • 13
  • 3

1 Answers1

0
Route::set('admin/backend/shop', 'admin/backend/shop(/<controller>(/<action>(/<overflow>)))',
    array('action' => '(force)', 'overflow' => '.*?')
    )->defaults(array(
        'directory' => 'admin_backend_shop',
        'controller' => 'index',
        'action'     => 'index',
    ));

Route::set('admin', 'admin(/<controller>(/<param_action>(/<overflow>)))',
    array('param_action' => '(update|view)', 'overflow' => '.*?'))
    ->defaults(array(
        'directory' => 'admin',
        'controller' => 'index',
        'action'     => 'index',
    ));

Ended up working!

jim brown
  • 13
  • 3