keine Ahnung ob es das schon für die 4.9 gibt, das Beispielmodul navigation_lang_changer hat bei mir immer nur eine Sprache zum wechseln angezeigt.
Deshalb habe ich es kurz überarbeitet, bitte testen, Feedback erwünscht:
Modul Output:
Code: Alles auswählen
<?php
/**
* Description: Navigation Language Switcher
* Note: Adapted from NavigationLangChanger
*
* @package Module
* @subpackage NavigationLanguage
* @version SVN Revision $Rev:$
*
* @author Stephan Lang
* @author alexander.scheider@4fb.de
* @copyright four for business AG <www.4fb.de>
* @license http://www.contenido.org/license/LIZENZ.txt
* @link http://www.4fb.de
* @link http://www.contenido.org
*/
// 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;
}
}
// 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;
}
array_push($data, array('langID' => $langs,
'label' => $languageCollectionInstance->getLanguageName($langs),
'title' => $languageCollectionInstance->getLanguageName($langs),
'url' => $url));
}
}
}
// use template to display navigation
$smarty = cSmartyFrontend::getInstance();
$smarty->assign('languages', $data);
$smarty->display('get.tpl');
?>
Modul-Template:
Code: Alles auswählen
<!-- navigation_language/template/get.tpl -->
<div id="navigation_language">
{foreach from=$languages item=wrapper}
{assign var="langID" value=$wrapper.langID}
{assign var="label" value=$wrapper.label}
{assign var="title" value=$wrapper.title}
{assign var="url" value=$wrapper.url}
<a href="{$url}" title="{$title}"><image class="flag" alt="{$label}" title="{$label}" src="images/{$label}.png" /></a>
{/foreach}
</div>
<!-- /navigation_language/template/get.tpl -->
Ist noch nicht im Produktiv Einsatz, könnten also noch Bugs drinnen sein...
Viel Spass damit
Stephan