[eluser]Mark LaDoux[/eluser]
// updated (got a partial script done now, there's a bug, but it should work.
// If you see where i slipped up, let me know
Ok, what i want to do is this. I want to reroute everything in my default controller in such away that I never have to type the controllers class into the url bar. Basically skip segment one and go right on to segment two. I want to do this dynamically so if I add functions, i don't have to do another route entry.
Ah, if that weren't easy enough?? I also want to set up an array, where if the name is in their, it would route those controllers normally overriding the automatic class removal.
Let me give you an idea of what I'm talking about...
Only problem with it is I get a blank page, no errors, no output, no nothing.
Code:
$route['default_controller'] = "site";
$route['scaffolding_trigger'] = "";
/*
$installed_controllers = array();
*/
$exclude = array('.', '..', 'index.html', 'site.php');
$dir = APPPATH.'controllers/';
$handle = opendir($dir);
// lets make this work --
$handle = opendir($dir);
while(false !== ($file = readdir($handle)))
{
if (!in_array($file, $exclude))
{
$installed_controllers[] = $file;
}
}
closedir($handle);
// testing, remove once i get output
die(print_r($installed_controllers))
foreach($installed_controllers as $control)
{
$route[$control] = $control;
$route[$control.'/(.*)'] = $control.'/$1';
}
$route['(.*)'] = "site/$1";