-
Lang selector
Hi,
I've looked everywhere I could in the forum to find what I need.
I would like to have a text link in my header for lang selection. This is already done and is working. But how i could have this link show only the unactive lang and hide the active lang ??
Thanx for any help
maximil
-
Re: Lang selector
Hi again,
I would like to display a text link of the unactive language (and thus, hide the active lang) in my header. I was able to display the lang flags but not the text and all my available lang are displayed ??
Thanx again for any help
Maximil
-
Re: Lang selector
You would have to create custom code to exclude the current language from displaying. Is there a real benefit to this?
-
Re: Lang selector
The only benefits it would provide are aesthetical of course. The french guy buying (i hope) on my site really doesn't need to have displayed the french flag or text title !!
That's why i want to get rid of the "other" text title.
Still want to help me ??
Here's my actual code
<?php
$lng = new language;
$languages_string = '';
reset($lng->catalog_languages);
$lng_cnt = 0;
while (list($key, $value) = each($lng->catalog_languages)) {
$languages_string .= '<a href="' . zen_href_link($_GET['main_page'], zen_get_all_get_params(array('language', 'currency')) . 'language=' . $key, $request_type) . '" class="lang">' . zen_image(DIR_WS_LANGUAGES . $value['directory'] . '/images/' . $value['name'], $value['name']) . '</a>;';
$lng_cnt ++;
}
echo $languages_string;
?>
I tweaked the two $value and inserted the 'name' in it. But it doesn't seem to work in IE, only in FF ??
Maximil
-
Re: Lang selector
Anyone out there willing to help me ???
Thanks
-
Re: Lang selector
I have the opposite approach.
I want to highlight the language which is selected by the users who come from different zones and with different customs.
I am modifying the mod of Language/Currency Links in Header and under testing.
The code logic below works for me. You may refer and modify it for you purpose.
PHP Code:
while (list($key, $value) = each($lng->catalog_languages)) {
// If current languages_id NOT matched with the returned languages id
if (!($_SESSION['languages_id'] == $value['id'])) {
// display normal effect for languages and flags
$content .= '<div id="navLanguages"><a href="' . zen_href_link($_GET['main_page'], zen_get_all_get_params(array('language', 'currency')) . 'language=' . $key, $request_type) . '">' . zen_image(DIR_WS_LANGUAGES . $value['directory'] . '/images/' . $value['image'], $value['name']) . '</a></div>';
} else {
// If current language_id matched with the returned languages id, display special effect for selected language and flag
$content .= '<div id="navLanguagesSelected"><a href="' . zen_href_link($_GET['main_page'], zen_get_all_get_params(array('language', 'currency')) . 'language=' . $key, $request_type) . '">' . zen_image(DIR_WS_LANGUAGES . $value['directory'] . '/images/' . $value['image'], $value['name']) . '</a></div>';
}
}
echo $content;
-
Re: Lang selector
Hi,
I'm still looking for a way to display only the unactive lang. Since i'm really not a good PHPer :down: i'm asking for help. I came able to make this code
PHP Code:
<?php if ( ???) {
<a href="<?php echo zen_href_link($_GET['main_page'], zen_get_all_get_params(array('language', 'currency')) . 'language=en'); >">English</a>
} else {
<a href="<?php echo zen_href_link($_GET['main_page'], zen_get_all_get_params(array('language', 'currency')) . 'language=fr'); ?>">Français</a>
}
?>
What is the variable that I could place instead of the if (???) ... Is there a variable that indicates which is the active lang ??? With that i could says something like :
if (en is active) display french
else
display english
Thanks
Maximil
-
Re: Lang selector
Hi,
finaly made it:smartass: here's the code :
PHP Code:
<?php
if (!($_SESSION['languages_id'] == '3')) {
?>
<a href="<?php echo zen_href_link($_GET['main_page'], zen_get_all_get_params(array('language', 'currency')) . 'language=en'); ?>">English</a>
<?php } else { ?>
<a href="<?php echo zen_href_link($_GET['main_page'], zen_get_all_get_params(array('language', 'currency')) . 'language=fr'); ?>">Français</a>
<?php } ?>
One can change the languages_id and the links to match his settings
Maximil
-
Re: Lang selector
They key is
$_SESSION['languages_id']
It is the language id that the user are using or selected
If you only have two languages, it is two by one choice or toggle on / off.
May be it can be simplified. :smile:
if (!$_SESSION['languages_id'])