Php – hmvc codeigniter routes modules controller function

codeigniterPHP

i have hmvc structure from https://bitbucket.org/wiredesignz/codeigniter-modular-extensions-hmvc

modules content, create controller news_event, and for function view to detail view
the structure like this

  • modules
    • content
      • controllers
        • news_event.php

in news_event.php

i having 3 function,index, view and pages

 function index() { $this->pages(); }

 function pages($_pages = 1){ ... }

 function view($_id_uri = false){ ... }

i had success make

http://example.com/ci_hmvc/content/news_event/

become

http://example.com/ci_hmvc/news_event/

but its error when its load next view

http://example.com/ci_hmvc/news_event/view/my-var-uri-friendly-here

i got error 404, but if i call with this url, success

http://example.com/ci_hmvc/content/news_event/view/my-var-uri-friendly-here

my routing code is

 $route['news_event'] = 'content/news_event';
 $route['news_event/(:any)'] = 'content/news_event/view/$1';

how routes, if i want to access with

http://example.com/ci_hmvc/news_event/view/my-var-uri-friendly-here

or this

http://example.com/ci_hmvc/news_event/my-var-uri-friendly-here

Best Answer

If your using a route file from within the module folder, the route name must start with the module name.

modules/content/config/routes.php

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

$route['content/'] = '';

You could add the route in the normal routing file

application/config/routes.php

$route['news_event'] = 'content/content/news_event';

The idea behind hmvc is to not call a module via the routing method, but rather call the module within the system itself(view or controller)

Modules::run('module/controller/method', $args);
Related Topic