Hi,
I'm trying to create a multilingual site and I've decided to go with the example shown here. The problem is that I'm also trying to build the site with a method I've never used before. The navigation is done through the get-method. All content gets loaded into the index file, depending on what is in the url different content gets loaded (e.g. ?page=home or ?page=contact). But in the index I include my file called navigation which looks like this (I've stripped the code so that it only contains what's necessary):
<?php
//Depending on the $navigation variable the site loads different content into the page
if ($navigation == 'home'){
home();
}
else {
firstPage();
}
//Here below is each function for each possible navigation option
#home
function home(){
include "php/header/mm-header.php";
include "php/home/mm-home.php";
}
function firstPage(){
include "php/first_page/mm-first_page.php";
}
?>
This is included in the index file.
so the page mm-home.php is included-included if you understand what I mean, it is included in a file that gets included. This is because I think it's much easier working with smaller files
I forgot to mention that when you first come to the site you get the option to view it in either english or an alternative language and after that you are redirected to the home-page.
The problem I face is that I need the language variable that is created in the index file, not through inclusion, to work in mm-home.php. The way I do it looks like this:
//Fetching the information needed to navigate the site
$navigation = mysql_real_escape_string($_GET['page']);
if (isset($_GET['lang'])){
$_SESSION['lang'] = mysql_real_escape_string($_GET['lang']);
}
else {
$_SESSION['lang'] = 'en';
}
//Getting the correct language
$directory = 'languages';
include_once($directory.'/'.$_SESSION['lang'].'.lng');
I've been trying different ways to get the variable $language, which I've in a last desperate attempt tried to use in a session, to work in the included-included file mm-home.php. Because it seems like the server processes the code in mm-home.php before it gets included or something. Or maybe it's processed when I include it the first time because the variable doesn't work in the content loaded from mm-home.php. It works if I load the language once again in mm-home.php but it seems like unnecessary much code, it must be a simpler way to do it.
Earlier I've tried to do this working purely with $_GET but it didn't work so that is why I've chosen to try sessions. Does anyone have any idea how I should do this?