• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
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.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.