Welcome Guest, Not a member yet? Register   Sign In
Cool tweak for site_url() (extension of url_helper)
#1

[eluser]mattalexx[/eluser]
Built into CI is the ability to call site_url() these ways:

Code:
site_url('products/view/123'); // or
site_url(array('products', 'view', 123));
But I wanted to write them this way:
Code:
site_url('products', 'view', 12); // or
site_url('products/view', 123); // or
site_url('products/view', 123, $another_variable);
So I wrote me some code:

APP/helpers/MY_url_helper.php:
Code:
function site_url($uri = '')
{
    if (func_num_args() > 1) {
        $args = func_get_args();
        $uri = implode('/', $args);
    }
    $CI = get_instance();
    return $CI->config->site_url($uri);
}
#2

[eluser]zamon[/eluser]
cool Smile




Theme © iAndrew 2016 - Forum software by © MyBB