Welcome Guest, Not a member yet? Register   Sign In
need help with multilanguage and routes
#1

[eluser]a.j.[/eluser]
Hi,

I have a problem:

there's a multilingual website for which I use CodeIgniter 1.7.3 and Internationalization (i18n) library for CodeIgniter.

Here is my controler:

Code:
<?php

class News extends Controller {

    function News()
    {
        parent::Controller();    
        $this->lang->load('main');
        $this->load->helper('language');
        $this->load->model('news_model');
        $this->load->library('pagination');
    }

    function index()
    {
      $data['news'] = $this->news_model->getNewsList();
      $data['menu_bar'] = $this->load->view('bars/menu-bar', $data, true);
      $data['content_bar'] = $this->load->view('news', $data, true);
      $this->load->view('template', $data);
    }

    function show_single()
    {
      $data=$this->news_model->showSingleByUri();
       if (!empty($data['id'])) {  
         $data['menu_bar'] = $this->load->view('bars/menu-bar', $data, true);
         $data['content_bar'] = $this->load->view('news_single', $data, true);
         $this->load->view('template', $data);
       } else redirect(base_url());
    }
}

mysite/fr/news - I get news list, it's ok
mysite/fr/news/show_single/seo-subject-of-content - I get single content, it's ok

but is it possible to hide name of function 'show_single' and make uri like this?

mysite/fr/news/seo-subject-of-content
mysite/en/news/seo-subject-of-content

Without multilanguage library it would be easy:

config/routes.php:

Code:
$route['news/(:any)'] = 'news/show_single/$1/';

But this way is not proper while according to multilanguage library I have to use URI routing like this:

Code:
$route['default_controller'] = news;

// URI like '/en/about' -> use controller 'about'
$route['^fr/(.+)$'] = "$1";
$route['^en/(.+)$'] = "$1";

// '/en' and '/fr' URIs -> use default controller
$route['^fr$'] = $route['default_controller'];
$route['^en$'] = $route['default_controller'];

Could you help me? I didn't find any solutions in forum. Or should I look for other multilanguage libraries? Please share with your experience.

Thanks in advance.




Theme © iAndrew 2016 - Forum software by © MyBB