Welcome Guest, Not a member yet? Register   Sign In
Dynamic Route to Specific Controller
#11

[eluser]solepixel[/eluser]
Ok, this is what I ended up with:

Code:
global $DB_ROUTES;

list($uri, $qs) = (strpos($_SERVER['REQUEST_URI'], '?') !== false) ? explode('?', $_SERVER['REQUEST_URI']) : array($_SERVER['REQUEST_URI'],'');

$route = $uri;


if($uri != '/'){
    $uri = trim($uri, '/');
    
    $route = trim($route, '/');
    $route = str_replace('-', '_', $route);
}
if($row->controller){
    $path = ($row->controller == '/') ? 'index_controller' : trim($row->controller, '/');
    
    if($path != $uri){
    
        $route_uri = trim($row->uri, '/');
        $remainder = '/'.trim(str_replace($route_uri, '', $uri), '/');
        if($remainder == '/'){
            $remainder = '';
        }
            
        $uri = str_replace('-', '_', $uri);
        $DB_ROUTES[$uri] = $path.$remainder;
        $DB_ROUTES[$uri.'/(.*)'] = $path.$remainder.'/$1';
            
    }
        
} else {
    // insert index into global variable
    $DB_ROUTES[$route] = 'content/'.(($uri == '/') ? 'root' : $uri);
}


Messages In This Thread
Dynamic Route to Specific Controller - by El Forum - 06-30-2010, 12:55 PM
Dynamic Route to Specific Controller - by El Forum - 06-30-2010, 01:34 PM
Dynamic Route to Specific Controller - by El Forum - 06-30-2010, 02:08 PM
Dynamic Route to Specific Controller - by El Forum - 06-30-2010, 04:05 PM
Dynamic Route to Specific Controller - by El Forum - 06-30-2010, 05:18 PM
Dynamic Route to Specific Controller - by El Forum - 06-30-2010, 09:10 PM
Dynamic Route to Specific Controller - by El Forum - 07-01-2010, 07:45 AM
Dynamic Route to Specific Controller - by El Forum - 07-01-2010, 07:57 AM
Dynamic Route to Specific Controller - by El Forum - 07-01-2010, 08:10 AM
Dynamic Route to Specific Controller - by El Forum - 07-01-2010, 08:23 AM
Dynamic Route to Specific Controller - by El Forum - 07-01-2010, 10:16 AM
Dynamic Route to Specific Controller - by El Forum - 07-01-2010, 10:27 PM



Theme © iAndrew 2016 - Forum software by © MyBB