Welcome Guest, Not a member yet? Register   Sign In
Dynamic pages, best practices for routing/parsing
#2

[eluser]Colin Williams[/eluser]
Don't forget that, in any aspect of your CI application, you have a unique, handy little tool: PHP

Code:
// All the langs we support
$langs = array('en','es','ru','se');

// Get at our first segment after index.php. Might need to adjust. Check your $_SERVER['REQUEST_URI']
list($i, $j, $check) = explode('/', $_SERVER['REQUEST_URI']);

// See if we found a match to our $langs
if (in_array($check, $langs))
{
   $_SESSION['lang'] = $check; // Set in a superglobal for later reference
   $route[$check] = ""; // Route to homepage
   $route[$check .'/(.*)'] = "$1"; // Route to everything after lang
}


Messages In This Thread
Dynamic pages, best practices for routing/parsing - by El Forum - 08-05-2008, 03:22 AM
Dynamic pages, best practices for routing/parsing - by El Forum - 08-05-2008, 05:11 AM
Dynamic pages, best practices for routing/parsing - by El Forum - 08-05-2008, 05:23 AM
Dynamic pages, best practices for routing/parsing - by El Forum - 08-05-2008, 05:31 AM
Dynamic pages, best practices for routing/parsing - by El Forum - 08-05-2008, 05:34 AM
Dynamic pages, best practices for routing/parsing - by El Forum - 08-13-2008, 02:21 AM



Theme © iAndrew 2016 - Forum software by © MyBB