Post by terawatt » Tue Jan 10, 2012 4:44 pm

Hi all!

How to do this - when changing language to change site logo. Sample:
For English - logo.jpg
For Russian - logo2.jpg

My OpenCart version is 1.5.0.5.

Thanks in advance...

Newbie

Posts

Joined
Tue Jan 10, 2012 4:39 pm

Post by uksitebuilder » Mon Jan 16, 2012 10:53 pm

Wrap your logo in your header.tpl file in php conditional statements like this

edit: catalog/view/theme/yourtheme/template/common/header.tpl

find

Code: Select all

  <?php if ($logo) { ?>
  <div id="logo"><a href="<?php echo $home; ?>"><img src="<?php echo $logo; ?>" title="<?php echo $name; ?>" alt="<?php echo $name; ?>" /></a></div>
  <?php } ?>
change to

Code: Select all

  <?php if (!isset($_COOKIE['language']) && $logo) { ?>
  <div id="logo"><a href="<?php echo $home; ?>"><img src="<?php echo $logo; ?>" title="<?php echo $name; ?>" alt="<?php echo $name; ?>" /></a></div>
  <?php } ?>
  <?php if (isset($_COOKIE['language']) && $_COOKIE['language']=='en' && $logo) { ?>
  <div id="logo"><a href="<?php echo $home; ?>"><img src="<?php echo $logo; ?>" title="<?php echo $name; ?>" alt="<?php echo $name; ?>" /></a></div>
  <?php } ?>
for each additional language add after the above change the following

Code: Select all

  <?php if (isset($_COOKIE['language']) && $_COOKIE['language']=='de') { ?>
  <div id="logo"><a href="<?php echo $home; ?>"><img src="image/data/logo_de.jpg" title="<?php echo $name; ?>" alt="<?php echo $name; ?>" /></a></div>
  <?php } ?>

ImageImageImageImage

For Friendly Professional Support - Click Here


User avatar
Guru Member

Posts

Joined
Thu Jun 09, 2011 11:37 pm
Location - United Kindgom

Post by terawatt » Mon Mar 19, 2012 8:09 pm

This is my code in header.tpl:

Code: Select all

  <?php if (isset($_COOKIE['language']) && $logo) { ?>
  <div id="logo"><a href="<?php echo $home; ?>"><img src="<?php echo $logo; ?>" title="<?php echo $name; ?>" alt="<?php echo $name; ?>" /></a></div>
  <?php } ?>
  <?php if (isset($_COOKIE['language']) && $_COOKIE['language']=='bg' && $logo) { ?>
  <div id="logo"><a href="<?php echo $home; ?>"><img src="<?php echo $logo; ?>" title="<?php echo $name; ?>" alt="<?php echo $name; ?>" /></a></div>
  <?php } ?>
   <?php if (isset($_COOKIE['language']) && $_COOKIE['language']=='en') { ?>
  <div id="logo"><a href="<?php echo $home; ?>"><img src="image/data/logo2.png" title="<?php echo $name; ?>" alt="<?php echo $name; ?>" /></a></div>
  <?php } ?>
and the following happens:
1. When I click the EN flag - the logo doesn't changes to logo2. After that when I click the EN flag again or BG flag - logo and logo2 are displayed simultaneously.
2. At this point: if 1 click the BG flag - only BG flag is displayed. If 1 click the EN flag - both logos are visible simultaneously.
Something is wrong here. What should I do?

Newbie

Posts

Joined
Tue Jan 10, 2012 4:39 pm

Post by uksitebuilder » Tue Mar 20, 2012 1:02 am

you didnt do the code edit correctly, see my post above

ImageImageImageImage

For Friendly Professional Support - Click Here


User avatar
Guru Member

Posts

Joined
Thu Jun 09, 2011 11:37 pm
Location - United Kindgom

Post by terawatt » Thu Mar 22, 2012 12:49 am

My default language is Bulgarian(BG) or Russian(RU). And I change to English via country flag.

As you told me I did the following:

Code: Select all

  <?php if !isset($_COOKIE['language']) && $logo) { ?>
  <div id="logo"><a href="<?php echo $home; ?>"><img src="<?php echo $logo; ?>" title="<?php echo $name; ?>" alt="<?php echo $name; ?>" /></a></div>
  <?php } ?>
  <?php if isset($_COOKIE['language']) && $_COOKIE['language']=='bg' && $logo) { ?>
  <div id="logo"><a href="<?php echo $home; ?>"><img src="<?php echo $logo; ?>" title="<?php echo $name; ?>" alt="<?php echo $name; ?>" /></a></div>
  <?php } ?>
The error I get is:
Parse error: syntax error, unexpected '!', expecting '(' in shop\catalog\view\theme\yooseren\template\common\header.tpl on line 51
Therefor I change the code to:

Code: Select all

  <?php if (!isset($_COOKIE['language']) && $logo) { ?>
  <div id="logo"><a href="<?php echo $home; ?>"><img src="<?php echo $logo; ?>" title="<?php echo $name; ?>" alt="<?php echo $name; ?>" /></a></div>
  <?php } ?>
  <?php if (isset($_COOKIE['language']) && $_COOKIE['language']=='bg' && $logo) { ?>
  <div id="logo"><a href="<?php echo $home; ?>"><img src="<?php echo $logo; ?>" title="<?php echo $name; ?>" alt="<?php echo $name; ?>" /></a></div>
  <?php } ?>
but the logo for the default language is not dislayed. So I remove the "!" symbol and its visible now.
For the additional (english) language, I use this code again with "(" in front of ISSET function cause it return me error (Parse error: syntax error, unexpected T_ISSET, expecting '(' in ...):

Code: Select all

<?php if isset($_COOKIE['language']) && $_COOKIE['language']=='en') { ?>
  <div id="logo"><a href="<?php echo $home; ?>"><img src="image/data/logo2.jpg" title="<?php echo $name; ?>" alt="<?php echo $name; ?>" /></a></div>
  <?php } ?>
and the sutiation is as described in my previos post.

Newbie

Posts

Joined
Tue Jan 10, 2012 4:39 pm

Post by gabbya » Sun May 06, 2012 11:40 pm

having the same problem logo dos not change.

User avatar
New member

Posts

Joined
Sun May 06, 2012 11:39 pm

Post by gabbya » Mon May 07, 2012 6:21 am

OK i found best way opencart 1.5.2.1
edit file catalog/view/theme/yourtheme/template/common/header.tpl

replace:
<?php if ($logo) { ?>
<div id="logo"><a href="<?php echo $home; ?>"><img src="<?php echo $logo; ?>" title="<?php echo $name; ?>" alt="<?php echo $name; ?>" /></a></div>
<?php } ?>

///////with

<?php
if($lang == 'he'){
$logo = 'image/data/logo_he.png';
} elseif($lang == 'ar'){
$logo = 'image/data/logo_ar.png';
} elseif($lang == 'ru'){
$logo = 'image/data/logo_ru.png';
}else {
$logo = 'image/data/logo_en.png'; //or image/data/logo.png
}
?>
<?php if ($logo) { ?>
<div id="logo"><a href="<?php echo $home; ?>"><img src="<?php echo $logo; ?>" title="<?php echo $name; ?>" alt="<?php echo $name; ?>" /></a></div>
<?php } ?>

///// :) change the name of you logo by the lang. you are all welcome

User avatar
New member

Posts

Joined
Sun May 06, 2012 11:39 pm

Post by gabbya » Sat May 12, 2012 11:12 pm


User avatar
New member

Posts

Joined
Sun May 06, 2012 11:39 pm

Post by pezfish » Thu Jul 11, 2013 6:54 am

gabbya wrote:OK i found best way opencart 1.5.2.1
edit file catalog/view/theme/yourtheme/template/common/header.tpl

replace:
<?php if ($logo) { ?>
<div id="logo"><a href="<?php echo $home; ?>"><img src="<?php echo $logo; ?>" title="<?php echo $name; ?>" alt="<?php echo $name; ?>" /></a></div>
<?php } ?>

///////with

<?php
if($lang == 'he'){
$logo = 'image/data/logo_he.png';
} elseif($lang == 'ar'){
$logo = 'image/data/logo_ar.png';
} elseif($lang == 'ru'){
$logo = 'image/data/logo_ru.png';
}else {
$logo = 'image/data/logo_en.png'; //or image/data/logo.png
}
?>
<?php if ($logo) { ?>
<div id="logo"><a href="<?php echo $home; ?>"><img src="<?php echo $logo; ?>" title="<?php echo $name; ?>" alt="<?php echo $name; ?>" /></a></div>
<?php } ?>

///// :) change the name of you logo by the lang. you are all welcome

Thanks a bunch. This worked like a charm. :)
(OC 1.5.5.1)

Newbie

Posts

Joined
Wed Apr 03, 2013 4:32 pm

Post by Jonnyisrael » Sun Jul 27, 2014 8:38 am

this also works with the latest OC version 1.5.6.4, thank you

Newbie

Posts

Joined
Wed Jul 23, 2014 7:56 pm

Post by mohidul » Sun Jul 23, 2017 11:20 am

I found the better solution
<?php if ($logo) { ?>
<div id="logo">
<a href="<?php echo $home; ?>"><img src="<?php if($_SESSION['language']=='bn'){ echo " image/data/logo_bn.png "; } else { echo $logo; } ?>" title="<?php if($_SESSION['language']=='bn'){ echo "অংশ বাজার"; } else { echo $name; } ?>" alt="<?php if($_SESSION['language']=='bn'){ echo "অংশ বাজার"; } else { echo $alt; } ?>" />
</a>
</div>
<?php } ?>
visit my store also http://ongshobazar.com

Mohidul Islam


Newbie

Posts

Joined
Thu Oct 25, 2012 5:08 pm
Location - Jessore, Bangladesh
Who is online

Users browsing this forum: No registered users and 45 guests