• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
HMVC and Admin

I am currently using HMVC and Phil Sturgeon's method of creating admin panel for the backend of my websites.

The problem is that sometimes the admin controller in each module can get too large and managing code much less tracking it down can be difficult.

For example, the current admin controller, let's admin_photos is used to manage photos, photo categories, tags, with each probably their own CRUD functions. Is there a way I can break this into 3 different admin controllers while still being under the Photos module.

Essentially, I am looking for something like this:

------- admin_photos.php
------- admin_tags.php
------- admin_categories.php

I would like to be able to access the backend using http://sitename.com/admin/photos/tags etc..

Is that possible?


HMVC supports routing for a module separately from the application-wide routing. As the wiki on bitbucket says

Quote:Each module may contain a config/routes.php file where routing and a default controller can be defined for that module using:
$route[‘module_name’] = ‘controller_name’;

Here's my approach from another recent project:

$route['admin/(:any)/(:any)'] = '$1/admin/$2';
$route['admin/(:any)'] = '$1/admin/index';

$route['admin/photo/tags/(:any)'] = 'photo/admin_tags/$2';
$route['admin/photo/tags'] = 'photo/admin_tags/index';
$route['admin/photo/categories/(:any)'] = 'photo/admin_categories/$2';
$route['admin/photo/categories'] = 'photo/admin_categories/index';

I'm not 100% sure whether this works this way - I had the second part put directly into ./application/config/routes.php. And always remember for routes: first come first serve.

Hi PhilTerm,

Thanks, for some reason. I can never get modules routes working. Up until now, I have been sticking all my routes in the main routes file. Tried the above but can seem to get it to work.

Any ideas?

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.