Welcome Guest, Not a member yet? Register   Sign In
SEO URIs *AND* $_GET requests - /controller/function/?myvar=1
#1

[eluser]Pygon[/eluser]
After being annoyed for the longest time with CI's handling of _GET requests while using SEO friendly URIs, I decided to come up with a solution.

So far, I've not run into any problems, however this is fairly fresh and lightly tested.



app/lib/MY_URI.php
Code:
<?php
class MY_URI extends CI_URI {
    
    function MY_URI()
    {
        $this->config =& load_class('Config');

        //Config using query strings?
        if( $this->config->item('enable_query_strings') !== TRUE )
        {
            //Save a copy of $_GET for later.
            global $_backup_get;
            $_backup_get = $_GET;

            //Clean any references URI might use
            $_GET = array();
            $_SERVER['QUERY_STRING'] = "";
        }

        parent::CI_URI();
    
    }
}
?>

app/lib/MY_Input.php
Code:
<?php
class MY_Input extends CI_Input {
    
    function MY_Input()
    {
        parent::CI_Input();

        $this->config =& load_class('Config');
        
        //Using query strings?
        if($this->config->item('enable_query_strings') !== TRUE)
        {
            //Process as normal
            parent::CI_Input();

            global $_backup_get;
            
            //Repopulate $_GET from URI
            $_GET = $_backup_get;

            unset($_backup_get);
            
            //Clean  $_GET Data
            foreach($_GET as $key => $val)
            {
                $_GET[$this->_clean_input_keys($key)] = $this->_clean_input_data($val);
            }
        }
    }
}
?>

Access as normal using $this->input->get()


Messages In This Thread
SEO URIs *AND* $_GET requests - /controller/function/?myvar=1 - by El Forum - 02-26-2008, 04:51 PM



Theme © iAndrew 2016 - Forum software by © MyBB