What Sothink DHTML Menu Can Do for You?
Multiple Languages
Sothink DHTML Menu :
Same menu for all languages by using variables in the item text
Part 1: Overview
If you manage a multi-lingual site and use DHTMLMenu to create guide menu, it's a annoying work to make a same dhtml menu in deferent language. But now you can use variables to create one menu for all languages.
In this example, we create only one menu, but it can show in English and French language.
Part 2: Steps
The following are the steps of this example:
- In the DHTML Menu program, check HTML button, and input <?php echo($strMenuText); ?> in the text field, and do uncheck "Encode special characters" in the advanced of Global Settings.
- Insert the menu code into the php page.
- Add following script in the page's body code:
<?php
define("LANGUAGE_ENGLISH", 0);
define("LANGUAGE_FRENCH", 1);
$nLanguage = LANGUAGE_ENGLISH;
$strMenuText = "";
switch($nLanguage)
{
case LANGUAGE_ENGLISH:
$strMenuText = "Hello";
break;
case LANGUAGE_FRENCH:
$strMenuText = "bonjour";
break;
default:
$strMenuText = "Hello";
break;
}
?> - Save your page and check it in browser.
(Note: your server should support PHP.)
Part 3: Code Explanation
This is the source code at the beginning of this sample page.
Code |
Explanation |
<?php define("LANGUAGE_ENGLISH", 0); define("LANGUAGE_FRENCH", 1); |
Define macro. |
$nLanguage = LANGUAGE_ENGLISH; $strMenuText = ""; |
Define two variables: "nLanguage" and "strMenuText". |
switch($nLanguage) case LANGUAGE_ENGLISH: } |
Set to show the corresponding language in which condition. |
General Drop Down Menu
Clone Drop Down Menu
Special Drop Down Menu