21
General Help & Support / Re: Any idea how to put country flag to menu?
« Last post by sternchen8875 on May 02, 2024, 11:30:59 AM »Quote
I couldn't use the standard WB selector (wherever I put it it crashed the template)
wondering about that, but difficult to say, whats going wrong without some code
normalize its a copy&paste-job, but it need all the code from the example in the DefaultTemplate
At first, check the wb-seeting, part: general settings -> Multilingualism and activate it, if not active
here the code - #1 - put it into the index.php of your template, nearly to the top. it is php-code, so be sure, that you've the right place in the code
Code: [Select]
// fetch page language
$sPageLang = strtolower(isset($wb->page) || ($wb instanceof frontend) ? $wb->page['language'] : 'EN');
// fetch page_id for loaded page, you need it for canonical
$iPageId = (isset($wb->page) || ($wb instanceof frontend) ? $wb->page['page_id'] :(PAGE_ID ?? ($page_id ?? 0)));
// Dummy function if Lingual Snippet not loaded
if (!function_exists('LangPageId')) {
function LangPageId() {
global $iPageId;
return $iPageId;
}
}
// get the page_id from language in level 0 for a given language
if (\function_exists('getLangStartPageIds')) {
$iLangStartPage = (int)(getLangStartPageIds($sPageLang));
}
// get the page trail from languages in level 0 as array
$aLangStartPageIds = [];
if (\function_exists('getLangStartPageIds')) {
$aLangStartPageIds = getLangStartPageIds();
}
// to show flags in frontend
$iMultiLang = 0;
$iLangFound = count($aLangStartPageIds);
switch ($iLangFound):
case 0:
$iMultiLang = 1;
break;
case 1:
$iMultiLang = 0;
break;
default:
$iMultiLang = 1;
endswitch;
$sMultiLang = '';
if (function_exists('language_menu')) {
$sMultiLang = language_menu('png', false);
$iMultiLang = intval(!empty($sMultiLang) ? 1 : $iMultiLang);
}
#2 - this is the output from the flag-menu, put it into the body-area of your template (where you've the actual language menu-call). Its also php-code, maybe you have to put it between <?php and ?>
Quote
echo '<div >';
echo '<span id="lang" style="height: 2.925em;">';
if (trim($sMultiLang) != '') {
echo $sMultiLang;
}
echo '</span>';
echo '</div>';
here the css from the original, maybe, you need it
Quote
.langmenu { margin-left :auto; margin-right :auto; padding :5px 24px; min-height :0.6em; text-align :left; display :table-cell; vertical-align :middle; }
.langmenu {position: relative; }
.langmenu img { border :0; max-width: 100%; width: 34px; }
.langmenu a.default img { filter :alpha(opacity=100); -moz-opacity :1.0; opacity :1.0; }
.langmenu a:hover img,
.langmenu a.current img { filter :alpha(opacity=30); -moz-opacity :.3; opacity :.3; text-decoration: none; }
.langmenu a:hover { text-decoration: none; }
if you need help, please post the code of your used index.php from this template als zip-file here.
If you want to use your solution with this single link, we need the code for this