ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Cool tweak for site_url() (extension of url_helper)

September 17, 2010 1:33am

Subscribe [1]
  • #1 / Sep 17, 2010 1:33am

    mattalexx's avatar

    mattalexx

    59 posts

    Built into CI is the ability to call site_url() these ways:

    site_url('products/view/123'); // or
    site_url(array('products', 'view', 123));

    But I wanted to write them this way:

    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:

    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 / Sep 17, 2010 1:39am

    zamon

    3 posts

    cool 😊

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases