CodeIgniter Forums

Full Version: HMVC and Admin
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

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 etc..

Is that possible?


El Forum

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.

El Forum

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?