[eluser]gerben[/eluser]
This code builds upon Zacharias' wonderful Modular Separation. I've tested it with version 2.4.1
In my application I found it helpful to make the routing-rules for modules modular as well. This way, a module can be really plug-and-play, because you can add your module-specific routes within the module folder. I thought someone else might find it handy, that's why I post it
First, create a routes.php file in your module's config folder. This file will contain all your module-specific routes.
modules/module_name/config/routes.php
Then, in your default routes.php (application/config/routes.php) add the following lines:
Code:
// check for installed modules automatically
// if a module has a routes.php, include it
$exclude = array('.', '..', 'index.html');
$handle = opendir(APPPATH.'modules/');
while ( false !== ($file = readdir($handle)))
{
if(!in_array($file, $exclude))
{
$installed_modules[] = $file;
}
}
closedir($handle);
foreach($installed_modules as $module){
if(file_exists(APPPATH.'modules/'.$module.'/config/routes.php')){
include(APPPATH.'modules/'.$module.'/config/routes.php');
}
}
That's it! Have fun!