Hist : siberia problems when GET array manipulated with language buttons
Third of three posts on different aspects of this topic. The site uses the get array to keep track of which language to use in the interface and which string to query on. A third problem is that the elements which allowed the user to switch languages did not check for other values in the GET array, and so those were lost. Specifically, the value of the q key-value pair was lost, so if you changed languages, you got the default search returning all the values in the db.
Here's a simplified version of the problem code:
<div id="languages-c">
<h3><a title="English" href="?lang=english"> English</a></h3>
<h3><a title="Français" href="?lang=french"> Français</a></h3>
<h3><a title="Русский" href="?lang=russian"> Русский</a></h3>
</div>
and here's the replacement that retains the key-value pair for q as well:
<?php
$qInURL = "";
$conjunction = "&";
if (isset ($_GET['q'])) {
$qInURL .= $conjunction . 'q='. $_GET['q'];
}
?>
<div id="languages-c">
<h3><a title="English" href="?lang=english"> English</a></h3>
<h3><a title="Français" href="?lang=french<?php echo $qInURL ?>"> Français</a></h3>
<h3><a title="Русский" href="?lang=russian<?php echo $qInURL ?>"> Русский</a></h3>
</div>