Post by Heilong » Wed Nov 19, 2008 5:18 pm

Hi everyone,

My cart is using 2 languages french and english, i want to display different images if the user select english or french, is there any way to retrieve the language values ?

I tried this in the catalog/template/default/layout.tpl :

Code: Select all

	<?php
		if(isset($_REQUEST['language']) && $_REQUEST['language'] == 'en')
		{
			echo $_REQUEST['language'];
	?>
	<div id="homepage_image">
		ENGLISH
	</div>
	<?php
		}
		else
		{
			echo $_REQUEST['language'];
	?>
	<div id="homepage_image">
		FRANCAIS
	</div>
	<?php
		}
	?>
But it didn't work as I didn't retrieve the language value.

Any solutions ?

Thanks

New member

Posts

Joined
Mon Sep 01, 2008 5:57 pm

Post by JNeuhoff » Wed Nov 19, 2008 6:49 pm

If at all, the language value would be only available in $_POST['language'], and this only when it was submitted by the user when he was changing his language. The only safe way to accomplish what you plan to do is by doing this in your controller:

Code: Select all

....
$language =& $this->locator->get('language');
....
$view->set('image_name', ($language->getCode()=='en') ? 'english.gif' : 'french.gif');
....

And in your corresponding tpl file, it needs something like this:

Code: Select all

....
<img src="<?php echo 'image/'.$image_name; ?>" alt="whatever" />
....

Export/Import Tool * SpamBot Buster * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Tag Manager * Survey Plus * OpenTwig


User avatar
Guru Member

Posts

Joined
Wed Dec 05, 2007 3:38 am


Post by Heilong » Wed Nov 19, 2008 8:31 pm

And what about a text value which need to be change according to english or french choosen by the user.

Thanks,

New member

Posts

Joined
Mon Sep 01, 2008 5:57 pm

Post by bruce » Wed Nov 19, 2008 8:59 pm

That is exactly what the language files do. All text is chosen based on the language being displayed.

Active Member

Posts

Joined
Wed Dec 12, 2007 2:26 pm

Post by Heilong » Thu Nov 20, 2008 11:14 am

I was thinking to do something like that, as I already did for other additional text.

But for the file catalog/template/default/layout.tpl. There is no controller where I can input this code. That's why i tried to get the language values using $_REQUEST table.

New member

Posts

Joined
Mon Sep 01, 2008 5:57 pm
Who is online

Users browsing this forum: No registered users and 2 guests