Zen Cart Logo

Lang selector

Locked

Views: 4,332

Results 1 to 9 of 9
This thread is locked. New replies are disabled.
17 Sep 2006, 3:15 PM
#1
maximil avatar

maximil

New Zenner

Join Date:
Dec 2005
Posts:
20
Plugin Contributions:
0

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

18 Sep 2006, 1:05 AM
#2
maximil avatar

maximil

New Zenner

Join Date:
Dec 2005
Posts:
20
Plugin Contributions:
0

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

18 Sep 2006, 1:12 AM
#3
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Re: Lang selector

You would have to create custom code to exclude the current language from displaying. Is there a real benefit to this?

18 Sep 2006, 1:21 AM
#4
maximil avatar

maximil

New Zenner

Join Date:
Dec 2005
Posts:
20
Plugin Contributions:
0

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

22 Sep 2006, 1:59 AM
#5
maximil avatar

maximil

New Zenner

Join Date:
Dec 2005
Posts:
20
Plugin Contributions:
0

Re: Lang selector

Anyone out there willing to help me ???

Thanks

24 Sep 2006, 5:57 AM
#6
seethrou avatar

seethrou

Totally Zenned

Join Date:
May 2004
Location:
Hong Kong
Posts:
1,156
Plugin Contributions:
0

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.

  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;
19 Oct 2006, 9:49 PM
#7
maximil avatar

maximil

New Zenner

Join Date:
Dec 2005
Posts:
20
Plugin Contributions:
0

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

<?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
20 Oct 2006, 3:25 AM
#8
maximil avatar

maximil

New Zenner

Join Date:
Dec 2005
Posts:
20
Plugin Contributions:
0

Re: Lang selector

Hi,

finaly made it:smartass: here's the 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

20 Oct 2006, 4:09 AM
#9
seethrou avatar

seethrou

Totally Zenned

Join Date:
May 2004
Location:
Hong Kong
Posts:
1,156
Plugin Contributions:
0

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'])