Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

How to Switch logo images when switching languages


CD Monster

Recommended Posts

Hi,

 

I think I can figure this one out in a short time but maybe someone knows off the top of their head:

 

I run my site in two languages: English and Spanish. So when you come to the site you see a store logo in English. And the 2 flags (Eng & Spanish)

If you click on the Spanish flag, you get the site translated in Spanish including all buttons in Spanish as is provided by a contribution for buttons in another language.

So, I also want to show a Spanish language version of the logo which would include the same type of code to switch buttons:

<?php echo tep_draw_hidden_field('products_id', $product_info['products_id']) . tep_image_submit('button_in_cart.gif', IMAGE_BUTTON_IN_CART); ?>

 

The code above is the add to cart code where an image switch happens as well for language choice.. with me so far.

 

So I want to do the same for the logo when language switching. : tep_image_submit('button_in_cart.gif', IMAGE_BUTTON_IN_CART); ?>

Except my php skills suck so I dont want to get it wrong. I dont need an action called except the image switch.

Im aware the logos would have to reside in the language/english/images and languages/espanol/images folders.

I just want to get the code right. Right now my logo resides in the root/images folder so that would have to change.

 

Can someone swiftly jot the steps to take, its much appreciated and as always I will gladly pay you on Tuesday for the hamburger today.

 

Thanks,

CD Monster,

 

grrrrr....

Music is body splash for the soul.

Link to comment
Share on other sites

Here's a quick way - that could be refined. In header.php where the logo is called, replace it with this:

 

<?php if ($language == 'espanol') { echo '<a href="' . tep_href_link(FILENAME_DEFAULT) . '">' . tep_image(DIR_WS_IMAGES . 'logo_espanol.gif', 'Spanish Logo) . '</a>'; } else {  echo '<a href="' . tep_href_link(FILENAME_DEFAULT) . '">' . tep_image(DIR_WS_IMAGES . 'logo_english.gif', 'English Logo') . '</a>'; } ?>

 

You can keep both logos in the root/images directory. Obviously change the logo names to yours and backup header.php first.

Link to comment
Share on other sites

I add all language related images to my button folders, and call them simply with the tep_image_button(BUTTONNAME, BUTTON_HOVERTEXT) function

:-)

Monika

 

addicted to writing code ... can't get enough of databases either, LOL!

 

my toolbox: Textpad - Compare and Merge - phpMyAdmin - WS_FTP - Photoshop - How to search the forum

 

Interactive Media Award July 2007 ~ category E-Commerce

my advice on the forum is for free, PMs where you send me work are considered consultation which I charge for ...

Link to comment
Share on other sites

Wow !

 

2 good looking answers, which to choose... grrrr

 

I'll try them both, thanks you both!

 

So with HOVER_TEXT - this sounds like a rollover effect. I guess I'll see.

 

Monsta

Music is body splash for the soul.

Link to comment
Share on other sites

Here's a quick way - that could be refined. In header.php where the logo is called, replace it with this:

 

<?php if ($language == 'espanol') { echo '<a href="' . tep_href_link(FILENAME_DEFAULT) . '">' . tep_image(DIR_WS_IMAGES . 'logo_espanol.gif', 'Spanish Logo) . '</a>'; } else {  echo '<a href="' . tep_href_link(FILENAME_DEFAULT) . '">' . tep_image(DIR_WS_IMAGES . 'logo_english.gif', 'English Logo') . '</a>'; } ?>

 

You can keep both logos in the root/images directory. Obviously change the logo names to yours and backup header.php first.

 

Hi Spax,

 

I finally got around to trying this. But Im getting a simple syntax error= Parse error: syntax error, unexpected '/' in /home/content/html/switch.php on line 1. My php skills do not exist so outside of trying different characters where they dont belong Im stuck.

 

the code resides inside a table but that shouldn't matter because of the <php call. Can you or someone say how to correct the error.

 

Thanks again,

 

Monsta.

Music is body splash for the soul.

Link to comment
Share on other sites

We can't correct what we can't see! :-"

 

I've no idea what switch.php is but on line 1 should be <?php

 

Maybe you have something half commented out after, // is a comment. Post some code so we can see.

Link to comment
Share on other sites

Thanks for replying Spax,

 

I took your code as supplied and just replaced the image names, uploaded those both to my image folder and added your code to the header inside the table that displays the logo. Below is what I place in my includes/header.php: your right I could have supplied more info, good point.:

 

<td width=444>

<?php if ($language == 'espanol') { echo '<a href="' . tep_href_link(FILENAME_DEFAULT) . '">' . tep_image(DIR_WS_IMAGES . 'Logo_image_23.jpg', 'Spanish Logo) . '</a>'; }

else { echo '<a href="' . tep_href_link(FILENAME_DEFAULT) . '">' . tep_image(DIR_WS_IMAGES . 'Logo_image_24.jpg', 'English Logo') . '</a>'; } ?>

</td></tr>

<tr><td colspan=3 height=1></td></tr>

<table>

 

Standard header page but top is in table to center logo, etc.

 

Thanks - displays in my editor (Homesite) like code is incorrect, missing something.. error said .. syntax error, unexpected '/'

ps-switch.php was just a quick isolation test. same results

 

 

We can't correct what we can't see! :-"

 

I've no idea what switch.php is but on line 1 should be <?php

 

Maybe you have something half commented out after, // is a comment. Post some code so we can see.

Music is body splash for the soul.

Link to comment
Share on other sites

Monsta, I urge you to use my button method coding here. The method above I'd recommend if the user is taken to 2 different pages, but not here. It also does not have the flexibility to work for X languages (ok, so maybe you do not need that, but still!)

 

pack those 2 images into your button folders .. they need to have the SAME name ('Logo_image.jpg')

 

then use this:

 

<td width=444>
<?php echo '<a href="' . tep_href_link(FILENAME_DEFAULT) . '">' . tep_image_button('Logo_image.jpg', 'Logo') . '</a>';  ?>
</td></tr>
<tr><td colspan=3 height=1></td></tr> 
<table>

:-)

Monika

 

addicted to writing code ... can't get enough of databases either, LOL!

 

my toolbox: Textpad - Compare and Merge - phpMyAdmin - WS_FTP - Photoshop - How to search the forum

 

Interactive Media Award July 2007 ~ category E-Commerce

my advice on the forum is for free, PMs where you send me work are considered consultation which I charge for ...

Link to comment
Share on other sites

Ga naaaaaa wwwwwwww!!!!!

 

Monika,

 

It worked !!!

 

I never doubted you, I just didn't know how to code the hover image. IT WORKED !!!!! YOU DID IT AGAIN !!!!!! !!!!!!

Thank you Monika.

 

Only slight problem is:

My logo image is sliced into six images and put together in a table and Mapped where different images link to different pages.

I need to add the image =width & height & border or it creates spaces around the images. I can add cellspace=0, things like that, vspace=0,

But much easier and neater if I can add the width, height and border=0 to each image. And their link. Can that be done using the:

 

<?php echo '<a href="' . tep_href_link(FILENAME_DEFAULT) . '">' . tep_image_button('logo_3.jpg', 'this is alternate text') . '</a>'; ?>

I need something like:

<a href=<?=tep_href_link('products_new.php')?>> for the link for each image. I can use just a plain html anchor.

 

Thanks Again Monika.

Monsta.

Music is body splash for the soul.

Link to comment
Share on other sites

These do not create spaces between each other, if you add them all in one line - I use this in a gazillion pages. You need to just continue to add the images not starting a new line in your editor.

:-)

Monika

 

addicted to writing code ... can't get enough of databases either, LOL!

 

my toolbox: Textpad - Compare and Merge - phpMyAdmin - WS_FTP - Photoshop - How to search the forum

 

Interactive Media Award July 2007 ~ category E-Commerce

my advice on the forum is for free, PMs where you send me work are considered consultation which I charge for ...

Link to comment
Share on other sites

ok, I will try, I only tested on one of the six images, maybe thats why the space. I will try all and let you know the results. Just in case is there a way to add the image 'height''width''border'.. ? never mind I will try..

Music is body splash for the soul.

Link to comment
Share on other sites

Of course there is a way. The tep_image_button is a function that has the 3rd parameter for styles, classes, width etc.

 

Check out your includes/functions/html_output.php file. A real eyeopener, at least it was for me when I first looked.

 

But you will not need it if you code the section correctly.

:-)

Monika

 

addicted to writing code ... can't get enough of databases either, LOL!

 

my toolbox: Textpad - Compare and Merge - phpMyAdmin - WS_FTP - Photoshop - How to search the forum

 

Interactive Media Award July 2007 ~ category E-Commerce

my advice on the forum is for free, PMs where you send me work are considered consultation which I charge for ...

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...