• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
language in admin panel

Hello i need a little help. I have Codeigniter framework in my cms. I want to select language from selection bar in admin panel. When i select language in selection bar it write to session, but how too get this sessioned language to config file that config file will write this language?

Soo, with this code $this->session->userdata('selected_language'); i get language, but how i rewrite config file everytime when i change language? In config.php file is string called $config['language'] where i can insert language,but this is static string and change after i write other language, if i dont defind language in config.php file there is file Language.php which has code:

$CI =& get_instance();
$deft_lang = $CI->config->item('language');
$idiom = ($deft_lang == '') ? 'slovene' : $deft_lang;

Here at $deft_lang i need to get language from session but how? I try with $deft_lang = $this->session->userdata('selected_language'); but it doesnt work.

Have you tried this?
$this->config->set_item('language', $this->session->userdata('selected_language'));

A good place to set this would be in an admin base controller.

Doesnt work, i get error:
Fatal error: Call to a member function set_item() on a non-object in C:\AppServ\www\htdocscms\system\libraries\Language.php on line 64

Line 64:

$deft_lang = $this->config->set_item('language', $this->session->userdata('selected_language'));

Then you are not using this code in a controller Wink

If you want to set the language in config.php you had better use PHP sessions. CI config loads before the session library library, so you will not have access to the session library there.

isset($_SESSION['selected_language']) || $_SESSION['selected_language'] = 'slovene';
$config['language'] = $_SESSION['selected_language']);

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.