FAQ Detail

Question : How can i remove language segment from the url?

Answer :

Please follow the instructions below
Modify ROOT/application/helpers/My_url_helper.php file. Change the site_url() function like below
               
                if ( ! function_exists('site_url'))
                {

                    function site_url($uri = '',$lang='')

                    {

                        $CI =& get_instance();

                        $lang = '';

                        $final_url = $CI->config->site_url($lang.'/'.$uri);

                        //$final_url = str_replace('http://','https://',$final_url);

                        return $final_url;

                    }

                }
                
Download Router.txt From this link. Rename it to Router.php and replace ROOT/application/third_party/MX/Router.php file with it. Remember to backup old file before replacing. Rename it to Router.php Now edit ROOT/application/config/routes.php file and change the entrys like. For whizbiz
    $route['default_controller'] = "show";
    $route['404_override']          = "show/show404";
    $route['admin/users'] = "admin/users";
    $route['users'] = "show/members";
    $route['list-business']         = "user/new_ad";
    $route['choose-package'] = "user/payment/choosepackage";
    $route['create-ad']         = "user/create_ad";
    $route['edit-business/(:any)'] = "user/editpost/$1/$2";
    $route['update-ad']         = "user/updatepost";
    $route['admin/business/locations']  = "admin/business/locations";
    $route['locations']         = "show/location";
    $route['location-posts/(:any)'] = "show/location_posts/$1/$2";
    $route['profile/(:any)'] = "show/memberposts/$1/$2";
    $route['blog-posts'] = "show/post/blog";
    $route['news-posts'] = "show/post/news";
    $route['article-posts'] = "show/post/article";
    $route['post-detail/(:any)'] = "show/postdetail/$1/$2";
    $route['admin/page/(:any)'] = "admin/page/$1";
    $route['page/(:any)'] = "show/page/$1";
    $route['contact'] = "show/contact";
    $route['sendcontactemail'] = "show/sendcontactemail";
    $route['advancesearch'] = "show/search";
    $route['results'] = "show/result";
    $route['results/(:any)'] = "show/result/$1";
    $route['tags/(:any)'] = "show/tag/$1";
    $route['ads/(:any)'] = "show/detail/$1";
    $route['(:any)/embed/(:any)'] = "show/embed/$1";
    $route['(:any)/meme/(:any)'] = "show/detail";
    $route['(:any)/video/(:any)'] = "tv/v";
For autocon
    $route['default_controller'] = "show";
    $route['404_override']          = 'show/memento404';
    $route['meme/(:any)'] = "show/detail";
    $route['video/(:any)'] = "tv/v";
    $route['tags/(:any)'] = "show/tag/$1";
    $route['embed/(:any)'] = "show/embed/$1";
for Carbiz
    $route['default_controller']                     = "show";
    $route['404_override']                              = "show/show404";

    $route['admin/users']                             = "admin/users";
    $route['users']                                 = "show/members";
    $route['users/(:any)']                             = "show/members/$2";
    $route['post-ad']                                 = "user/new_ad";
    $route['choose-package']                         = "user/payment/choosepackage";
    $route['create-ad']                             = "user/create_ad";
    $route['edit-car/(:any)']                         = "user/editpost/$2/$3";
    $route['edit-car/(:any)/(:any)']                 = "user/editpost/$2/$3/$4";
    $route['update-ad']                             = "user/updatepost";
    $route['admin/content/locations']                  = "admin/content/locations";
    $route['locations']                             = "show/location";
    $route['location-posts/(:any)/(:any)/(:any)']     = "show/location_posts/$2/$3/$4";
    $route['profile/(:any)']                         = "show/memberposts/$2/$3";
    $route['profile/(:any)/(:any)']                 = "show/memberposts/$2/$3/$4";
    $route['categories']                             = "show/categories"; 
    $route['pricing']                                 = "show/pricing"; 
    $route['terms_and_conditions']                     = "show/page/terms_and_conditions"; 
    $route['cookie_policy']                         = "show/page/cookie_policy"; 
    $route['featured-cars']                         = "show/featured_cars"; 
    $route['blog-posts']                             = "show/post/blog";
    $route['news-posts']                             = "show/post/news";
    $route['article-posts']                         = "show/post/article";
    $route['blog-posts/(:any)']                     = "show/post/blog/$2";
    $route['news-posts/(:any)']                     = "show/post/news/$2";
    $route['article-posts/(:any)']                     = "show/post/article/$2";
    $route['post-detail/(:any)/(:any)']             = "show/postdetail/$2/$3/$4";
    $route['admin/page/(:any)']                     = "admin/page/$2";
    $route['page/(:any)']                             = "show/page/$2";
    $route['contact']                                 = "show/contact";
    $route['sendcontactemail']                         = "show/sendcontactemail";
    $route['advancesearch']                         = "show/search";
    $route['results']                                 = "show/result";
    $route['results/(:any)']                         = "show/result/$2";
    $route['tags/(:any)']                             = "show/tag/$2";
    $route['car/(:any)']                             = "show/detail/$2";
    $route['embed/(:any)']                             = "show/embed/$2";   
At last override the lang_key() function on ROOT/application/helpers/MY-dbcbase_helper.php like For autocon update it to
       
if ( ! function_exists('lang_key'))
{
    function lang_key($key='')
    {
        if(defined('LANG_ARRAY'))
        {
            $lang = json_decode(constant('LANG_ARRAY'));
            return (isset($lang->$key))?$lang->$key:$key;               
        }
        else
        {
            $CI = get_instance();
            $CI->load->database();
            $curr_lang  = $CI->uri->segment(1);
            $curr_lang = '';

            $default_lang = default_lang();
                
            if($curr_lang=='')
                $query = $CI->db->get_where('language',array('short_name'=>$default_lang,'status'=>1));
            else
                $query = $CI->db->get_where('language',array('short_name'=>$curr_lang,'status'=>1));

            if($query->num_rows()>0)
            {
                $row = $query->row();
                if(!defined('LANG_ARRAY'))
                    define('LANG_ARRAY',$row->values);

                $lang = json_decode($row->values);
                return (isset($lang->$key))?$lang->$key:$key;               
            }
            else
                return $key;
            
        }
    }
}
For whizbiz and carbiz update it to . For carbiz you'll find this function on webbase_helper.php
    if ( ! function_exists('lang_key'))
    {
        function lang_key($key='')
        {
            if(defined('LANG_ARRAY'))
            {
                $lang = (array)json_decode(constant('LANG_ARRAY'));
                if(isset($lang[$key]))
                    return $lang[$key];
                else {
                    if(constant("ENVIRONMENT")=='development') {

                        $myfile = fopen("missing_lang.txt", "a") or die("Unable to open file!");
                        $txt = $key."\n";
                        fwrite($myfile, $txt);
                        fclose($myfile);
                    }
                    return $key;
                }               
            }
            else
            {
                $CI = get_instance();
                $curr_lang  = '';

                $default_lang = default_lang();
                    
                if($curr_lang=='')
                    $file_name = $default_lang.'.yml';
                else
                {
                    if(!@file_exists(FCPATH."dbc_config/locals/".$curr_lang.'.yml'))
                    {
                        $file_name = $default_lang.'.yml';
                    }
                    else
                    {                   
                        $file_name = $curr_lang.'.yml';
                    }
                }

                $CI->load->library('yaml');
                $lang =  $CI->yaml->parse_file('./dbc_config/locals/'.$file_name);

                if(count($lang)>0)
                {
                    if(!defined('LANG_ARRAY'))
                        define('LANG_ARRAY',json_encode($lang));

                    if(isset($lang[$key]))
                        return $lang[$key];
                    else {
                        if(constant("ENVIRONMENT")=='development') {
                            $myfile = fopen("missing_lang.txt", "a") or die("Unable to open file!");
                            $txt = $key."\n";
                            fwrite($myfile, $txt);
                            fclose($myfile);
                        }
                        return $key;
                    }
                }
                else {
                    if(constant("ENVIRONMENT")=='development') {
                        $myfile = fopen("missing_lang.txt", "a") or die("Unable to open file!");
                        $txt = $key."\n";
                        fwrite($myfile, $txt);
                        fclose($myfile);
                    }
                    return $key;
                }
                
            }
        }
    }
At last for whizbiz edit ROOT/system/helpers/dbcbase_helper.php file and chnage the get_current_lang() function to
    if ( ! function_exists('get_current_lang'))
    {
        function get_current_lang()
        {
            
            return default_lang();  
        }
    }
Paginition issue on all business page on whizbix fix Fix: in admin/controllers/business_core.php
 
    public function allposts_ajax($start='0'){
    configPagination('admin/business/allposts',$total,5,$this->per_page);
    to
    configPagination('admin/business/allposts',$total,4,$this->per_page);

    in admin/views/default/business/all_posts_view.php
    $curr_page = $this->uri->segment(5);
    to
    $curr_page = $this->uri->segment(4);
    and
    var start = 'uri->segment("5")!="")?$this->uri->segment("5"):0;?>';
    to
    var start = 'uri->segment("4")!="")?$this->uri->segment("4"):0;?>';

    in admin/views/default/business/all_posts_ajax_view.php
    $curr_page = $this->uri->segment(5);
    to
    $curr_page = $this->uri->segment(4);