Code: Alles auswählen
<?php
// create instances and init vars
$catCollection = new cApiCategoryLanguageCollection();
$artCollection = new cApiArticleLanguageCollection();
$languageCollectionInstance = new cApiLanguageCollection();
$clientsLangInstance = new cApiClientLanguageCollection();
$languageInstance = new cApiLanguage();
$checkedCatArt = false;
$idcatAuto = cRegistry::getCategoryId();
$artRetItem = NULL;
$currentLanguage = NULL;
$clientId = cRegistry::getClientId();
$data = array();
// get all client language id's
$clientsLangInstance->select("idclient= " . $clientId);
$resultClientLangs = $clientsLangInstance->fetchArray('idlang', 'idlang');
// get all active languages of a client
foreach ($resultClientLangs as $clientLang) {
$languageInstance->loadByMany(array(
'active' => '1',
'idlang' => $clientLang
));
if ($languageInstance->get('idlang')) {
$allLanguages[] = $languageInstance->get('idlang');
}
$languageInstance = new cApiLanguage();
}
if (empty($allLanguages)) {
// if no languages present do nothing
echo "No languages present";
exit();
} else if (count($allLanguages) != 1) {
// else check if there more as one language
$currentLanguage = cRegistry::getLanguageId();
// set next language and id
foreach ($allLanguages as $langs) {
$catCheck = $catCollection->select("idcat = " . $idcatAuto . " AND " . " idlang = " . $langs . " AND " . "startidartlang != 0", NULL, NULL, NULL);
$catRetItem = new cApiCategoryLanguage();
$catRetItem->loadByCategoryIdAndLanguageId($idcatAuto, $langs);
if ($catCheck === true && $catRetItem) {
$artRetItem = $artCollection->fetchById($catRetItem->get('startidartlang'));
if ($artRetItem) {
if ($artRetItem->get('online') == 1 && $artRetItem->get('locked') == 0) {
$checkedCatArt = true;
}
}
// #### PLATZMARKER ###
// if check is true then set url, otherwise check for next language
if ($checkedCatArt === true) {
$url = $catRetItem->getLink($langs);
} else {
$config = cRegistry::getClientConfig(cRegistry::getClientId());
$url = cRegistry::getFrontendUrl() . 'front_content.php?idart='.$idart.'&changelang=' . $langs;
}
$lang_name=$languageCollectionInstance->getLanguageName($langs);
if($langs==1 |$langs==3 | $langs==4 | $langs==5){
array_push($data, array('langID' => $langs,
'label' => $lang_name,
'title' => $lang_name,
'url' => $url));
}
}
}
}
function split_lang($langN){
$data = preg_split('/ /', $langN, -1);
return $data;
}
function map_lang($lang){
$default = $lang;
$lang = strtolower($lang);
echo $lang;
switch($lang){
case "german":
$data="Deutsch";
break;
case "english":
$data="English";
break;
case "russian":
$data="Русский";
break;
case "chinese":
$data="中";
break;
default:
$data = $default;
return $data;
}
}
if($_GET['sasu_debug']) print_r($data);
// use template to display navigation
$smarty = cSmartyFrontend::getInstance();
$smarty->assign('languages', $data);
$smarty->display('get.tpl');
?>
Um das zu verhindern habe ich folgendes an der Stelle des ### PLATZMARKER### eingefügt:
Code: Alles auswählen
$articleLanguageCollection = new cApiArticleLanguageCollection();
$articleLanguageCollection -> select("idlang=$langs AND idart=$idart AND online=1");
while (false !== $articleLanguage = $articleLanguageCollection -> next()) {
$checkedCatArt = false;
}
Sobald ich jedoch dieses articleLanguageCollection nutze, werden die URL für den Language-Switcher nicht mehr von AMR umgeschrieben.
Warum? Wie kann ich das beheben?