Welcome Guest, Not a member yet? Register   Sign In
Route Helper
#1

[eluser]Pascal Kriete[/eluser]
Personally I extended the URL helper, but route helper seemed like a good name.

I've seen several people ask how they can get the current directory / controller / function since the release of 1.6, so I thought I should share.

Should be pretty self-explanatory.
Code:
function url_directory() {
    $route =& load_class('Router');
    $dir = substr_replace($route->directory, '', -1);  //Remove trailing slash
    return $dir;
}

function url_class() {
    $route =& load_class('Router');
    return $route->class;
}

function url_method() {
    $route =& load_class('Router');
    return $route->method;
}

function get_full_url() {
    $CI =& get_instance();
    $route =& load_class('Router');
    
    $full_route = $route->directory . $route->class.'/'.$route->method;
    return $full_route;
}

If anyone can tell me if this works with multiple directories (i.e. matchbox), that would be great.




Theme © iAndrew 2016 - Forum software by © MyBB