Welcome Guest, Not a member yet? Register   Sign In
HMVC problem: routes.php within module config dir not working
#8

[eluser]Unknown[/eluser]
@Mr. Pickle

I'm sure you've figured this out by now.

Code:
/* use module route if available */
if (isset($segments[0]) AND $routes = Modules::parse_routes($segments[0], implode('/', $segments))) {
$segments = $routes;
}

As you can see from the excerpt above taken from MX_Router, the code doesn't even consider any of the module's routes unless the first URI segment matches the module name.

So in your application/modules/news/config/routes.php file, any $route whose key does not start with news/ will not be considered.

For instance, the following will work as we expect:
Code:
$route['news/es'] = 'news/index';

But this will not:
Code:
$route['es/news'] = 'news/index';

As you've discovered the es/news example will work in the global routes file application/config/routes.php.

I agree that modules' routes.php files should not have this URI requirement. While modules are meant to organize code, Code Igniter routes is an application-wide feature and a module's routes should be able to rewrite at the root of the URI.

@wiredesignz

What are your thoughts on this? Is there a design reason why it was implemented this way? Perhaps all routes in modular routes file should be considered regardless of the request URI?

Thanks for any response, and great job on MX HMVC.


Messages In This Thread
HMVC problem: routes.php within module config dir not working - by El Forum - 04-05-2012, 11:30 AM



Theme © iAndrew 2016 - Forum software by © MyBB