Multiple language menu in template
I am creating a multiple language site, and as such, am using a session variable to select which menu to load.
The block I added to my template is as follows…
<div id="topNavigation">
<?php switch ($_SESSION['language']) {
case 'english': //use the english menu
require_once("../CSSMenuWriter/cssmw/menu.php");
break;
case 'spanish': //use the spanish menu
require_once("../CSSMenuWriter/cssmw/spanish/menu.php");
break;
case 'mandarin': //use the mandarin menu
require_once("../CSSMenuWriter/cssmw/mandarin/menu.php");
break;
case 'hindi': //use the hindi menu
require_once("../CSSMenuWriter/cssmw/hindi/menu.php");
break;
default: //use the english menu
require_once("../CSSMenuWriter/cssmw/menu.php");
}
?>
</div>
Any pages based on this template which occur in a subfolder, work perfectly, the code above is inserted exactly as above onto my page.
However, pages in the root folder, based on the same template do not work properly, the menu block appears as follows, with the first require line (only) missing the leading ../
I would expect all of the require lines to point to CSSMenuWriter...
<div id="topNavigation">
<?php switch ($_SESSION['language']) {
case 'english': //use the english menu
require_once("CSSMenuWriter/cssmw/menu.php");
break;
case 'spanish': //use the spanish menu
require_once("../CSSMenuWriter/cssmw/spanish/menu.php");
break;
case 'mandarin': //use the mandarin menu
require_once("../CSSMenuWriter/cssmw/mandarin/menu.php");
break;
case 'hindi': //use the hindi menu
require_once("../CSSMenuWriter/cssmw/hindi/menu.php");
break;
default: //use the english menu
require_once("../CSSMenuWriter/cssmw/menu.php");
}
?>
</div>
I could create another template specifically for files in the root folder, but this seems daft. Is there something else i can do ?