Welcome Guest, Not a member yet? Register   Sign In
Menus and Other
#1

[eluser]Gewa[/eluser]
Hi, I am a newbee in this forum and in CodeInteger. So I need some help.
I am making first web-site on CI and I need to make it multilingual. Its a catalog of bars and restaurants of our city. I tried to use the i18 way, but there you have to for each page make separate view of the site ( ex. menu_en.php, menu_de.php and so on) . But all the data like (menu_id, lang, menu_name) i like to have in my mysql, and load it and this is all. Just what is a problem that I want to load it one time, and just have it in my hand to give to views. Is it possible to load it direct in View files? How is better to make the multilingual site without using i18 core extension?
maybe some code examples? THanks beforehand.
#2

[eluser]wiredesignz[/eluser]
Try a forum search on using languages and maybe take a look at the URI Language Identifier link in my signature.

Good Luck and Welcome to the forums.
#3

[eluser]Gewa[/eluser]
[quote author="wiredesignz" date="1209225268"]Try a forum search on using languages and maybe take a look at the URI Language Identifier link in my signature.

Good Luck and Welcome to the forums.[/quote]



http://codeigniter.com/wiki/URI_Language_Identifier/


I checked it. Just didn't get how to use it. Lets say user goes to mysite.com/en/catalog/detailed/44


it will open controller catalog.php, load the detailed(44) right?

Then inside, how i get the language to make right quiery to base to take right mysql data?
#4

[eluser]wiredesignz[/eluser]
Use the configuration to set language settings as shown on the wiki, create your translation files for the languages you wish to use, the URI Identifier will be added automatically to site_url()'s within your application. Changing a language is as easy as hardcoding a link containing a new language identifier.

The $config->item{'language_abbr') will contain the currently selected identifier.
#5

[eluser]Gewa[/eluser]
you didn;t get me.

Lets say we have in our catalog.php controller function detailed() which shows the description of item....

Code:
function detailed($lid){


if(!$lid){
     exit("Please don;t play with URL");
     }




$query=$this->db->query("SELECT * FROM `lokal` WHERE `lid` = '$lid'");
                   if($query->num_rows()==0){

                     $this->load->view('header',$data);
                    $this->load->view('topmenu');
                     $this->load->view('menu');

                     echo" There is no such place with ID $lid";
                     exit;
                     }

                    if ($query->num_rows() > 0)
                         {
                            $data= $query->row_array();

                            }


                       $this->load->helper('date');
                     $datestring = "Year: %Y Month: %m Day: %d - %h:%i %a";
                       $time = time();
                       $data['zhamanak']=mdate($datestring, $time);
                        $data['city']="Vienna";
                        $data['subcategory']="Restoran";


                    $this->load->view('header',$data);
                    $this->load->view('topmenu');
                     $this->load->view('menu');
                     $this->load->view('detailed',$data);
                          $this->load->view('footer');
                 }


lets say i want to add internationalisation



what i do? I should have right $language to make such query

$query=$this->db->query("SELECT * FROM `lokal` WHERE `lid` = '$lid' AND lang='$language'");



which function will give me this $language, which is set in URI?


how to determine it inside the function?
#6

[eluser]wiredesignz[/eluser]
The $config->item{’language_abbr’) will contain the currently selected identifier and $config->item{’language’) will contain the currently selected language name.
#7

[eluser]Gewa[/eluser]
thank you!

found also this way. Which is better?

$lang=$this->uri->segment(1);
#8

[eluser]Gewa[/eluser]
[quote author="wiredesignz" date="1209226733"]The $config->item{’language_abbr’) will contain the currently selected identifier and $config->item{’language’) will contain the currently selected language name.[/quote]


the way you say gives


A PHP Error was encountered

Severity: Notice

Message: Undefined variable: config

Filename: controllers/catalog.php

Line Number: 69
#9

[eluser]wiredesignz[/eluser]
$uri->segment(1) will equal the identifier because it is added from $config() anyway, So use whichever suits.
#10

[eluser]wiredesignz[/eluser]
Everything is referenced to the Controller so use $this->config->item().




Theme © iAndrew 2016 - Forum software by © MyBB