Zen Cart Logo
Forums / Templates, Stylesheets, Page Layout / Two languages - two templates. Can this be done?

Two languages - two templates. Can this be done?

Locked

Views: 2,647

Results 1 to 15 of 15
This thread is locked. New replies are disabled.
11 Jul 2006, 2:50 PM
#1
zoreli avatar

zoreli

New Zenner

Join Date:
May 2005
Posts:
49
Plugin Contributions:
0

Two languages - two templates. Can this be done?

Hi

I create my custom template, in Greek language, in which I have images, custom meny etc. I edit the file tpl_header.php located in my custom template folder:

includes\templates\my_template\common

Now I would like to have different header with english images, english custom menu etc. so when somene click on english flag, he can see this different header. How this can be done?

Regards, Zoran

11 Jul 2006, 3:35 PM
#2
zoreli avatar

zoreli

New Zenner

Join Date:
May 2005
Posts:
49
Plugin Contributions:
0

Re: Two languages - two templates. Can this be done?

Never Mind, I found it

In case that some one else need the solution here it is:

Edit tpl_header.php located in your custom template folder:

includes\templates\my_template\common

<?php $language = $_GET['language']; if ( $language == 'el' ) { ?>

Your HTML table with menu in one language meny here

<?php } else { ?>

Your HTML with ENGLISH language meny and images here

<?php } ?>

Regards, Zoran

11 Jul 2006, 5:00 PM
#3
misty avatar

misty

Inactive

Join Date:
Apr 2004
Location:
UK
Posts:
5,752
Plugin Contributions:
1

Re: Two languages - two templates. Can this be done?

Good tip.. thanks for sharing
:smile:

13 Jul 2006, 4:53 PM
#4
zoreli avatar

zoreli

New Zenner

Join Date:
May 2005
Posts:
49
Plugin Contributions:
0

Re: Two languages - two templates. Can this be done?

Solution mentioned above doesn't work as it should. Since the query &language=en is not passed on all pages, I am loosing my second language navigation on next page.

Can this variable be stored in session?

Regards, Zoreli

13 Jul 2006, 4:57 PM
#5
sicness avatar

sicness

Zen Follower

Join Date:
Apr 2006
Location:
Sofia, Bulgaria
Posts:
195
Plugin Contributions:
0

Re: Two languages - two templates. Can this be done?

hmm
u can see the code in sideboxes/languages.php
and move it into header !!!

13 Jul 2006, 5:55 PM
#6
zoreli avatar

zoreli

New Zenner

Join Date:
May 2005
Posts:
49
Plugin Contributions:
0

Re: Two languages - two templates. Can this be done?

Didnt find anything useful inside.

I have to found how other links on the page know which language is used. Because only my custom links are loosing the language, while other (text) links works normaly.

Good try anyway.

Thanks, Zoreli

13 Jul 2006, 6:42 PM
#7
zoreli avatar

zoreli

New Zenner

Join Date:
May 2005
Posts:
49
Plugin Contributions:
0

Re: Two languages - two templates. Can this be done?

Solution was:
$language = $_SESSION['language'];

I had EN in my code and

$_SESSION['language']; return 'english', not 'en'

Now it works like a charm.

Regards, Zoreli

14 Jul 2006, 10:37 AM
#8
sicness avatar

sicness

Zen Follower

Join Date:
Apr 2006
Location:
Sofia, Bulgaria
Posts:
195
Plugin Contributions:
0

Re: Two languages - two templates. Can this be done?

do this will work with English and other one (nevermind what language) ?>

14 Jul 2006, 10:50 AM
#9
sicness avatar

sicness

Zen Follower

Join Date:
Apr 2006
Location:
Sofia, Bulgaria
Posts:
195
Plugin Contributions:
0

Re: Two languages - two templates. Can this be done?

I dont know Why but it shows me a blank page i cant make it
can give me the complete code couse not good in coding ?

14 Jul 2006, 12:12 PM
#10
zoreli avatar

zoreli

New Zenner

Join Date:
May 2005
Posts:
49
Plugin Contributions:
0

Re: Two languages - two templates. Can this be done?

sicness:

do this will work with English and other one (nevermind what language) ?>

Yes

sicness:

I dont know Why but it shows me a blank page i cant make it
can give me the complete code couse not good in coding ?

Edit tpl_header.php located in your custom template folder:

includes\templates\my_template\common

This is the only file that should be edited.

You should add your html meny in tpl_header.php. Did you do this and you are getting blank page?

Regards, Zoreli

14 Jul 2006, 1:19 PM
#11
sicness avatar

sicness

Zen Follower

Join Date:
Apr 2006
Location:
Sofia, Bulgaria
Posts:
195
Plugin Contributions:
0

Re: Two languages - two templates. Can this be done?

yes I tried to enter the code but i get a blank page i dont know to put it I mean

<?php
$language = $_SESSION['language'];

I had EN in my code and

$_SESSION['language']; return 'english', not 'en'
?>
Your HTML table with menu in one language meny here

<?php

} else {
?>

Your HTML with ENGLISH language meny and images here


<?php
}
?>

Is this what I have to enter and then what html code I have to enter for the images ?
give me some example ? to help orient somehow

14 Jul 2006, 1:44 PM
#12
zoreli avatar

zoreli

New Zenner

Join Date:
May 2005
Posts:
49
Plugin Contributions:
0

Re: Two languages - two templates. Can this be done?

Here is my code from tpl_header:

Copyright message was here.....So this is after the copyright of the message:

<?php //$_SESSION['language'] = $_GET['language']; //$language = $_GET['language']; //$language_page_directory = DIR_WS_LANGUAGES . $_SESSION['language'] . '/'; $lang = $_SESSION['language']; if ( $lang == 'greek') { ?> <table width="765" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td width="420" height="34" bgcolor="#ffffff"><img src="images/spacer.gif" width="1" height="34"></td> <td width="124" height="34"><a href="http://www.yourdomain.com/index.php?main_page=login"><img src="images/r1_c1.gif" width="124" height="34" border="0"></a></td> <td width="96" height="34"><a href="http://www.yourdomain.com/index.php?main_page=conditions"><img src="images/r1_c2.gif" width="96" height="34" border="0"></a></td> <td width="63" height="34"><a href="http://www.yourdomain.com/index.php?main_page=site_map"><img src="images/r1_c3.gif" width="63" height="34" border="0"></a></td> <td width="62" height="34" bgcolor="#ffffff"> </td> </tr> </table> <?php

} else {
?>

<table width="765" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td width="420" height="34" bgcolor="#ffffff"><img src="images/spacer.gif" width="1" height="34"></td> <td width="79" height="34"><a href="http://www.yourdomain.com/index.php?main_page=login"><img src="images/r1_c1_EN.gif" width="79" height="34" border="0"></a></td> <td width="90" height="34"><a href="http://www.yourdomain.com/index.php?main_page=conditions"><img src="images/r1_c2_EN.gif" width="90" height="34" border="0"></a></td> <td width="114" height="34"><a href="http://www.yourdomain.com/index.php?main_page=site_map"><img src="images/r1_c3_EN.gif" width="114" height="34" border="0"></a></td> <td width="62" height="34" bgcolor="#ffffff"> </td> </tr> </table> <?php } ?> <?php if ( $lang == 'greek' ) { ?> <table width="765" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF"> <tr> <td width="12" height="71" bgcolor="#ffffff"><img src="images/spacer.gif" width="1" height="71"></td> <td width="14" height="71"><img src="images/r2_c1.gif" width="14" height="71"></td> <td width="109" height="71"><img src="images/r2_c2.gif" width="109" height="71"></td> <td width="127" height="71"><img src="images/r2_c3.gif" width="127" height="71"></td> <td width="122" height="71"><img src="images/r2_c4.gif" width="122" height="71"></td> <td width="122" height="71"><img src="images/r2_c5.gif" width="122" height="71"></td> <td width="54" height="71"><img src="images/r2_c6.gif" width="54" height="71"></td> <td width="80" height="71"><img src="images/r2_c7.gif" width="80" height="71"></td> <td width="111" height="71"><img src="images/r2_c8.gif" width="111" height="71"></td> <td width="14" height="71" bgcolor="#ffffff"> </td> </tr> <tr> <td bgcolor="#ffffff" height="10" colspan="10"></td> </tr> </table> <?php } else { ?> <table width="765" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF"> <tr> <td width="12" height="71" bgcolor="#ffffff"><img src="images/spacer.gif" width="1" height="71"></td> <td width="14" height="71"><img src="images/r2_c1.gif" width="14" height="71"></td> <td width="109" height="71"><img src="images/r2_c2.gif" width="109" height="71"></td> <td width="127" height="71"><img src="images/r2_c3.gif" width="127" height="71"></td> <td width="122" height="71"><img src="images/r2_c4.gif" width="122" height="71"></td> <td width="122" height="71"><img src="images/r2_c5.gif" width="122" height="71"></td> <td width="54" height="71"><img src="images/r2_c6.gif" width="54" height="71"></td> <td width="80" height="71"><img src="images/r2_c7_EN.gif" width="80" height="71"></td> <td width="111" height="71"><img src="images/r2_c8_EN.gif" width="111" height="71"></td> <td width="14" height="71" bgcolor="#ffffff"> </td> </tr> <tr> <td bgcolor="#ffffff" height="10" colspan="10"></td> </tr> </table> <?php } ?> <?php if ( $lang == 'greek' ) { ?> <table width="765" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td width="12" height="29" bgcolor="#ffffff"><img src="images/spacer.gif" width="1" height="12"></td> <td width="66" height="29"><a href="http://www.yourdomain.com/index.php"><img src="images/r4_c1.gif" width="66" height="29" border="0"></a></td> <td width="160" height="29"><a href="http://www.yourdomain.com/index.php?main_page=index&cPath=7"><img src="images/r4_c2.gif" width="160" height="29"></a></td> <td width="120" height="29"><a href="http://www.yourdomain.com/index.php?main_page=products_new"><img src="images/r4_c3.gif" width="120" height="29" border="0"></a></td> <td width="146" height="29"><a href="http://www.yourdomain.com/index.php?main_page=products_all"><img src="images/r4_c4.gif" width="146" height="29" border="0"></a></td> <td width="97" height="29"><a href="advices.php"><img src="images/r4_c5.gif" width="97" height="29" border="0"></a></td> <td width="102" height="29"><a href="http://www.yourdomain.com/index.php?main_page=contact_us"><img src="images/r4_c6.gif" width="102" height="29" border="0"></a></td> <td width="48" height="29"><a href="http://www.yourdomain.com/index.php?main_page=gv_faq"><img src="images/r4_c7.gif" width="48" height="29" border="0"></a></td> <td width="14" height="29" bgcolor="#ffffff"><img src="images/spacer.gif" width="1" height="29"></td> </tr> <tr> <td bgcolor="#ffffff" height="10" colspan="10"></td> </tr> </table> <?php } else { ?> <table width="765" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td width="12" height="29" bgcolor="#ffffff"><img src="images/spacer.gif" width="1" height="12"></td> <td width="109" height="29"><a href="http://www.yourdomain.com/index.php"><img src="images/r4_c1_EN.gif" width="109" height="29" border="0"></a></td> <td width="118" height="29"><a href="http://www.yourdomain.com/index.php?main_page=index&cPath=7"><img src="images/r4_c2_EN.gif" width="118" height="29"></a></td> <td width="118" height="29"><a href="http://www.yourdomain.com/index.php?main_page=products_new"><img src="images/r4_c3_EN.gif" width="118" height="29" border="0"></a></td> <td width="169" height="29"><a href="http://www.yourdomain.com/index.php?main_page=products_all"><img src="images/r4_c4_EN.gif" width="169" height="29" border="0"></a></td> <td width="70" height="29"><a href="advices.php"><img src="images/r4_c5_EN.gif" width="70" height="29" border="0"></a></td> <td width="69" height="29"><a href="http://www.yourdomain.com/index.php?main_page=contact_us"><img src="images/r4_c6_EN.gif" width="69" height="29" border="0"></a></td> <td width="87" height="29"><a href="http://www.yourdomain.com/index.php?main_page=gv_faq"><img src="images/r4_c7_EN.gif" width="87" height="29" border="0"></a></td> <td width="14" height="29" bgcolor="#ffffff"><img src="images/spacer.gif" width="1" height="29"></td> </tr> <tr> <td bgcolor="#ffffff" height="10" colspan="10"></td> </tr> </table> <?php } ?>

...Code Continue here with:

<?php // Display all header alerts via messageStack: if ($messageStack->size('header') > 0) { echo $messageStack->output('header'); } if (isset($_GET['error_message']) && zen_not_null($_GET['error_message'])) { echo htmlspecialchars(urldecode($_GET['error_message'])); } if (isset($_GET['info_message']) && zen_not_null($_GET['info_message'])) { echo htmlspecialchars($_GET['info_message']); } else { } ?> <!--bof-header logo and navigation display-->

I cut the rest of the code...

Hope this help....

Regards, Zoran

14 Jul 2006, 1:58 PM
#13
sicness avatar

sicness

Zen Follower

Join Date:
Apr 2006
Location:
Sofia, Bulgaria
Posts:
195
Plugin Contributions:
0

Re: Two languages - two templates. Can this be done?

yes but did u thought that with this code it will redirect u whatever u are in, to the index ?
I mean if u looking some product U will wish to change the language and then will redirect u to the index ? but I will just want to see other lang version of the product ?

14 Jul 2006, 2:21 PM
#14
zoreli avatar

zoreli

New Zenner

Join Date:
May 2005
Posts:
49
Plugin Contributions:
0

Re: Two languages - two templates. Can this be done?

I send you the link in a PM, so you can see that everything work normally. Example if you are on page new products, and click on english button, you stay on same page (new products) just on english language. Same apply for all pages.

Regards, Zoreli

17 Jul 2006, 2:23 PM
#15
sicness avatar

sicness

Zen Follower

Join Date:
Apr 2006
Location:
Sofia, Bulgaria
Posts:
195
Plugin Contributions:
0

Re: Two languages - two templates. Can this be done?

Amm now I rewied the all threat and i found a missunderstanding

Actually I need a language selector in my tpl_header
And dont have an idea from where to get the code
I tried from sidebox/language.php but it wont work

do u have any idea

10x

Radoslav