• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
HMVC - Access several controllers for same module

Hello there,

I am using HMVC (https://bitbucket.org/wiredesignz/codeig...sions-hmvc).

But I have one question..

Is it possible to have several controllers in the same module folder ? Here is my folders :


How can I access by uri to admin controller ? I tried :


But its not works. Is there a way to do this ? Thanks !

That magic hides in application/config/routes.php. Here you are a real one from an application of mine:

$route['default_controller']                = 'home';

if (stripos($_SERVER['REQUEST_URI'], '/admin') !== false) {
    $route['404_override'] = 'admin/error_404';
} else {
    $route['404_override'] = 'error_404';

$route['translate_uri_dashes'] = TRUE;

$route['admin/([a-zA-Z_-]+)/(:num)']        = '$1/admin/index/$2';
$route['admin/([a-zA-Z_-]+)/(:num)/([a-zA-Z_-]+)'] = '$1/admin/$3/index/$2';
$route['admin/([a-zA-Z_-]+)/(:num)/([a-zA-Z_-]+)/([a-zA-Z_-]+)'] = '$1/admin/$3/$4/$2';
$route['admin/([a-zA-Z_-]+)/(:num)/([a-zA-Z_-]+)/([a-zA-Z_-]+)/(:num)'] = '$1/admin/$3/$4/$2/$5';
$route['admin/([a-zA-Z_-]+)/(.+)']          = '$1/admin/$2';
$route['admin/([a-zA-Z_-]+)']               = '$1/admin/index';

$route['([a-zA-Z_-]+)/(:num)']              = '$1/index/$2';
$route['([a-zA-Z_-]+)/(:num)/([a-zA-Z_-]+)/(:num)'] = '$1/$3/$2/$4';

$route['sitemap.xml']                       = 'sitemap/xml';

Not everything inside is related strictly to the subject. And this is a sample structure of an application:

                Admin.php (admin home)
                Error_404.php (for the public site)
                Home.php (public home)
                Admin_pages.php (admin home for "pages" module)
                Pages.php (public home for "pages")

This way is possible, I have real applications using it. But I don't like it. :-) I have two applications ("site" and "admin") and I am mixing artificially them within a single application.


It would be better "site" and "admin" applications to be implemented with separation and I am experimenting this next (logical) step.

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

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