Welcome Guest, Not a member yet? Register   Sign In
Getting the requested "format" from a route
#4

[eluser]ejangi[/eluser]
So I actually JUST got to this before reading the responses to this post. This is what I ended up putting in /libraries/MY_URI.php:
Code:
class MY_URI extends CI_URI {
    
    function MY_URI()
    {
        parent::CI_URI();
    }
    
    function format($default_return = false, $separator = '.')
    {
        $format = $default_return;
        if (count($this->router->segments)) {
            $last_segment = explode($separator, end($this->router->segments));
            if (count($last_segment) > 1) {
                $format = strtolower(end($last_segment));
            }
        }
        return $format;
    }
    
}

And in any controller I can now call:
Code:
echo $this->uri->format();


Messages In This Thread
Getting the requested "format" from a route - by El Forum - 12-12-2007, 04:44 PM
Getting the requested "format" from a route - by El Forum - 12-13-2007, 12:20 AM
Getting the requested "format" from a route - by El Forum - 12-13-2007, 01:36 AM
Getting the requested "format" from a route - by El Forum - 12-13-2007, 02:01 AM
Getting the requested "format" from a route - by El Forum - 12-14-2007, 12:09 AM
Getting the requested "format" from a route - by El Forum - 12-14-2007, 03:01 AM
Getting the requested "format" from a route - by El Forum - 12-14-2007, 09:09 AM
Getting the requested "format" from a route - by El Forum - 12-14-2007, 06:04 PM
Getting the requested "format" from a route - by El Forum - 12-14-2007, 06:06 PM
Getting the requested "format" from a route - by El Forum - 12-14-2007, 09:26 PM



Theme © iAndrew 2016 - Forum software by © MyBB