Designate Search language on the fly
Posted: Thu Dec 13, 2018 6:30 pm
If you want to present the search page in a language other than the language setup from the administration panel, this simple modification will do the trick.
Edit search.php. Very near the top, change
Finally, in each of the three functions, see the line
To use the modification, you add a command-line parameter when initially calling search.php. For example, you have English set as the Sphider default. a href='search.php" will bring up the search page in the default English. However, if you wish to show the page in Spanish, use href="search.php?sl=es". The search page will be in Spanish until the end of the session (or you call another language for another language such as href="search.php?sl=en" to revert back to English. If you are doing the call via a form, use action="search.php?sl=de" to bring up the search in German.
Edit search.php. Very near the top, change
toerror_reporting(0);
$include_dir = "./include";
Next, in the same file, scroll down to where you seeerror_reporting(0);
session_start();
$include_dir = "./include";
You will want to add 5 lines. You will end up withif (isset($_REQUEST['date3'])) {
$date3 = strip_tags($_REQUEST['date3']);
}
$include_dir = "./include";
Go down about 10 lines and findif (isset($_REQUEST['date3'])) {
$date3 = strip_tags($_REQUEST['date3']);
}
if (isset($_REQUEST['sl'])) {
$sl = strip_tags($_REQUEST['sl']);
} else {
$sl = $_SESSION['sl'];
}
$include_dir = "./include";
Add 4 lines, resulting inrequire $settings_dir."/conf.php";
require $include_dir."/detectmobilebrowser.php";
Go further down and there are three functions [ function tab1(), function tab2(), and function tab3() ]. In each of these three functions, you will see several lines of globals. You want to add $sl to each function as a global. An example with $sl added isrequire $settings_dir."/conf.php";
if ($sl == '') {
$sl = $language;
}
$_SESSION['sl'] = $sl;
require $include_dir."/detectmobilebrowser.php";
Not every line starting with "global" needs this... only once in each function.global $results, $start, $adv, $sl;
Finally, in each of the three functions, see the line
Add a line after, resulting ininclude $settings_dir."/conf.php";
Save and exit. The modification is complete.include $settings_dir."/conf.php";
$language=$sl;
To use the modification, you add a command-line parameter when initially calling search.php. For example, you have English set as the Sphider default. a href='search.php" will bring up the search page in the default English. However, if you wish to show the page in Spanish, use href="search.php?sl=es". The search page will be in Spanish until the end of the session (or you call another language for another language such as href="search.php?sl=en" to revert back to English. If you are doing the call via a form, use action="search.php?sl=de" to bring up the search in German.