CodeIgniter Forums
Extending CI_Config site_url() Localization - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Development (https://forum.codeigniter.com/forum-6.html)
+--- Forum: CodeIgniter 3.x (https://forum.codeigniter.com/forum-17.html)
+--- Thread: Extending CI_Config site_url() Localization (/thread-68682.html)



Extending CI_Config site_url() Localization - whisky - 08-12-2017

Refer to:
http://jeromejaglale.com/doc/php/codeigniter_i18n
https://github.com/waqleh/codeigniter-language-in-url-internationalization (2017 updated version of previous link)

So I included the github source for MY_Lang and MY_Config.

MY_Lang extends well and all functions work.

But MY_Config's site_url() does not work. site_url() should return the uri with localization 'en' etc such as 'en/about'.

Even having it echo and die in the beginning does not work.

MY_Config code :
class MY_Config extends CI_Config {
    function site_url($uri = '', $protocol = NULL) {
        if (is_array($uri)) {
            $uri = implode('/', $uri);
        }
        if (class_exists('CI_Controller')) {
            $CI = & get_instance();
            $uri = $CI->lang->localized($uri);
        }
        return parent:Confusedite_url($uri);
    }
}


RE: Extending CI_Config site_url() Localization - InsiteFX - 08-13-2017

Did you read all of the comments?


RE: Extending CI_Config site_url() Localization - whisky - 08-13-2017

Okay so interestingly, this doesn't work alongside HMVC (https://bitbucket.org/wiredesignz/codeigniter-modular-extensions-hmvc)

Anyone have any suggestions?


RE: Extending CI_Config site_url() Localization - whisky - 08-14-2017

Solved:
https://stackoverflow.com/questions/45666300/php-extend-class-conditionally-codeigniter-3-use-case/45678241#45678241