From 67fc68c9048cbbb51bf1b7cdbf6faf274f92ca5f Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Tue, 15 May 2012 11:22:16 -0400 Subject: [PATCH] routing tweaks --- sys/common.php | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/sys/common.php b/sys/common.php index 70ab714..b9824d0 100644 --- a/sys/common.php +++ b/sys/common.php @@ -263,7 +263,7 @@ function route() unset($custom_routes['default_controller']); unset($custom_routes['404_handler']); - foreach($custom_routes as $uri => $map) + foreach($custom_routes as $uri => &$map) { if (preg_match("`{$uri}`i", $pi)) { @@ -290,17 +290,25 @@ function route() $num_segments = count($segments); } + // Determine route based on uri segments if ($num_segments === 1) { $func = $pi; } - - if ($num_segments === 2) + elseif ($num_segments === 2) { - list($controller, $func) = $segments; + list($module, $controller) = $segments; + + // If it's just controller/function + if ($controller == 'index') + { + $controller = $module; + $module = $routes['default_module']; + $func = 'index'; + } + } - - if ($num_segments >= 3) + elseif ($num_segments >= 3) { list($module, $controller, $func) = $segments; }