Welcome Guest, Not a member yet? Register   Sign In
Multiple URL Suffix (SOLVED - UPDATED for CI 1.6.0)
#11

[eluser]m4rw3r[/eluser]
Here is another MY_URI.php, this one does not need a special router.php addition:

Code:
<?php
/**
* Modified URI class to enable multiple URL suffixes,
* and a function to retrieve which one is used.
* Separate the suffixes with commas (,).
*/
class MY_URI extends CI_URI{
    /**
     * Remove the suffix from the URL if needed, if a suffix is found, save it in $this->url_suffix.
     *
     * @access    private
     * @return    void
     */    
    function _remove_url_suffix()
    {
        $this->url_suffix = '';
        if  ($this->config->item('url_suffix') != ""){
            // go through every suffix and see if they match
            $suffixes = explode(',',$this->config->item('url_suffix'));
            foreach($suffixes as $suffix){
                $suffix = trim($suffix);
                if(preg_match("|".preg_quote($suffix)."$|", $this->uri_string)){
                    // We have match, remove the suffix and save which one in $this->url_suffix
                    $this->uri_string = preg_replace("|".preg_quote($suffix)."$|", "", $this->uri_string);
                    $this->url_suffix = $suffix;
                    break;
                }
            }
        }
    }
    /**
     * Returns the URL suffix used for this request.
     * @return string
     */
    function get_extension(){
        return $this->url_suffix;
    }
}
?>


Messages In This Thread
Multiple URL Suffix (SOLVED - UPDATED for CI 1.6.0) - by El Forum - 01-07-2008, 07:01 PM
Multiple URL Suffix (SOLVED - UPDATED for CI 1.6.0) - by El Forum - 01-07-2008, 08:33 PM
Multiple URL Suffix (SOLVED - UPDATED for CI 1.6.0) - by El Forum - 01-07-2008, 09:14 PM
Multiple URL Suffix (SOLVED - UPDATED for CI 1.6.0) - by El Forum - 01-08-2008, 12:06 AM
Multiple URL Suffix (SOLVED - UPDATED for CI 1.6.0) - by El Forum - 01-08-2008, 10:24 AM
Multiple URL Suffix (SOLVED - UPDATED for CI 1.6.0) - by El Forum - 01-08-2008, 05:19 PM
Multiple URL Suffix (SOLVED - UPDATED for CI 1.6.0) - by El Forum - 01-08-2008, 08:23 PM
Multiple URL Suffix (SOLVED - UPDATED for CI 1.6.0) - by El Forum - 02-07-2008, 06:15 PM
Multiple URL Suffix (SOLVED - UPDATED for CI 1.6.0) - by El Forum - 02-07-2008, 06:18 PM
Multiple URL Suffix (SOLVED - UPDATED for CI 1.6.0) - by El Forum - 02-20-2008, 06:50 AM
Multiple URL Suffix (SOLVED - UPDATED for CI 1.6.0) - by El Forum - 02-20-2008, 04:24 PM
Multiple URL Suffix (SOLVED - UPDATED for CI 1.6.0) - by El Forum - 02-20-2008, 07:22 PM
Multiple URL Suffix (SOLVED - UPDATED for CI 1.6.0) - by El Forum - 02-20-2008, 07:26 PM
Multiple URL Suffix (SOLVED - UPDATED for CI 1.6.0) - by El Forum - 02-20-2008, 08:25 PM
Multiple URL Suffix (SOLVED - UPDATED for CI 1.6.0) - by El Forum - 02-20-2008, 08:57 PM



Theme © iAndrew 2016 - Forum software by © MyBB