Seite 1 von 1

list/menu-select language

Verfasst: Do 21. Feb 2008, 11:43
von ilias
Can some body help me to make a list/menu on my site?
I want to make a list with 4 languages.And when I click on one of the menu's item I want to go to the page with the similar language.
The answer please in English

Verfasst: Fr 22. Feb 2008, 23:24
von HerrB
Not tested (and Contenido V4.6.23). This is one way ... (note, that the user needs JS activated...)

Code: Alles auswählen

<?php
cInclude("classes", "class.htmlelements.php");
cInclude("classes", "contenido/class.clientslang.php");
cInclude("classes", "contenido/class.lang.php");

oClientLangs = new cApiClientLanguageCollection();
oClientLangs->setWhere("idclient", $client);
oClientLangs->query();

$oSelLang = new cHTMLSelectElement("selLang");
// This JavaScript is REALLY WRONG - for sure, please fix by yourself
$oSelLang->setEvent("change", "document.href='front_content.php?idart=" . $idart . "&changelang=' + this.value");

while ($oClientLang = $oClientLangs->next()) {
   $iID = $oClientLang->get("idlang");
   $oLang = new cApiLanguage($iID);

   $oOption = new cHTMLOptionElement($oLang->get("name"), $iID);
   $oSelLang->addOptionElement($iID, $oOption);
}

echo $oSelLang->render();
?>