Jump to content

Quick.CMS and languange change?


InterNic

Recommended Posts

Hi,

i want to ask about the quick.cms system. There's a language changer, but when you change the language it turns you back immediately to the home page of the chosen language. I want it to stay on the same page. For example, if i opened the "About" section of the page in French, and click the link for the english version, i want it to expose the content of the "About" section in english, not the home page.

The script actually uses a get variable with the code of the language and sets a cookie to change it then.

Currently, my solution is the following (modified index.php):

 

session_start();	
include("core/files.php");

//languages equation
$clang['en'] = Array("home,1", "location,25", "about-antik,6", "useful-information,26", "prices,27", "gallery,28", "contacts,2", "beaches,31","sozopol,30", "antik-2,40", "antik-3,41", "antik-4,42");
$clang['bg'] = Array("hаcаlо,1", "Месtоpоlоzеhiе,2", "zа-kоmplеkса,7", "ihfоpmаcija,8", "cеhi,6", "gаlеpija,16", "kоhktаkti,11", "plаzоbе,13","Соzоpоl,15", "Аhtik-2,23", "Аhtik-3,26", "Аhtik-4,25");

if (!isset($_SESSION['clang']) && !isset($_COOKIE['sLanguage'])) $_SESSION['clang'] = "en"; //default language
if (isset($_GET['sLang'])) $_SESSION['clang'] = $_GET['sLang'];

if (!isset($_GET['sLang'])) {
$tmp = $_SERVER['REQUEST_URI'];

//$stack = strpos($tmp, ','); //only uri id
//full uri 
$stack = strpos($tmp, '?');
if (!$stack) {
	$fin = "";
}
else $fin = substr($tmp, ($stack+1), strlen($tmp));
$_SESSION['cpage'] = urldecode($fin);
$cl = $_SESSION['clang']; 
} else {
//
$cl = $_GET['sLang'];
print_r($_SESSION);
}

$corrlang = ($cl == "en") ? "bg" : "en";
for ($i = 0; $i < count($clang[$cl]); $i++) { 
	$cs = "loc," . $_SESSION['cpage'];
	//echo "cs: $cs";
	if ($_SESSION['cpage'] == $clang["$cl"][$i]) {
		$lindex = $i;
		$found = 1;
		//$_SESSION['cpage'] = 'location,25';
		break;
	}
}
if (!$found) {
//echo "<br/>not found!<br/>";
$i = 0;
}
else {
//echo "index is $lindex";
//echo "Corresponding file:";
if ($cl == "en") $cfile = $clang['bg'][$i];
elseif($cl == "bg") $cfile = $clang['en'][$i];
//echo $cfile;
}

 

Below (after $aActions):

if (!isset($_GET['sLang'])) $iContent = ( isset( $aActions['f'] ) && isset( $aActions['a'] ) && $aActions['f'] == 'p' && is_numeric( $aActions['a'] ) ) ? $aActions['a'] : $config['start_page'];
elseif(isset($_SESSION['corrlangi'])) $iContent = $_SESSION['corrlangi'];
else $iContent = 1;

 

As you might see that solution is quite undynammical. I use the array $clang['en'] and $clang['bg'] which stores the equal page in the equal index. But if another language/page is added i will have to add another array to the file manually with its equations. The cms stores the pages ids in the db/($LANG)_pages_ext.php. (In my case db/bg_pages_ext.php and db/en_pages_ext.php). So i can get the ids of the pages from these files, but i have no idea how to match them equally, because they're not in the same order. The cms is fully file-based and does not use any DB to store data. I will really appreciate any help regarding getting around the problem. Thanks!

Link to comment
https://forums.phpfreaks.com/topic/107157-quickcms-and-languange-change/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.