Zen Cart Logo
Forums / Templates, Stylesheets, Page Layout / tpl_header.php how to set different logos for each language?

tpl_header.php how to set different logos for each language?

Views: 1,032

Results 1 to 5 of 5
25 Mar 2013, 2:26 PM
#1
ilmarchez avatar

ilmarchez

Zen Follower

Join Date:
Aug 2009
Posts:
128
Plugin Contributions:
0

tpl_header.php how to set different logos for each language?

Hi,

I have two languages and I'd like to set different logos image for each language.
I tried to modify header.php in each language directory dut it doesn't work since the logo is set in themes/CUSTOM/common/tpl_header.php

How could I make this possible? the t/l_header.php is not inside any language folder, so do I need to change the code? How?

Thank you very much for your support, here you are the piece of code of tpl_header.php:

<a href="<?php echo zen_href_link(FILENAME_DEFAULT);?>"><?php echo zen_image(DIR_WS_TEMPLATE.'images/logo.gif'); ?>
25 Mar 2013, 2:46 PM
#2
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: tpl_header.php how to set different logos for each language?

Well, the original Zen Cart template contains language-dependent coding for the logo by calling HEADER_LOGO_IMAGE instead of 'images/logo.gif' specifically. Thus, your language files can contain the definition for HEADER_LOGO_IMAGE, and that way your template can be language-independent.

    <div id="logo"><?php echo '<a href="' . HTTP_SERVER . DIR_WS_CATALOG . '">' . zen_image($template->get_template_dir(HEADER_LOGO_IMAGE, DIR_WS_TEMPLATE, $current_page_base,'images'). '/' . HEADER_LOGO_IMAGE, HEADER_ALT_TEXT) . '</a>'; ?></div>

Alternatively, if your template contains numerous additional very-language-specific components, you could have a separate template for each language, and simply enable those separate templates in your Admin->Tools->Template Select screen. But this is RARELY needed, and I usually only see people do this when supporting both RTL and LTR languages.

25 Mar 2013, 2:47 PM
#3
schoolboy avatar

schoolboy

Totally Zenned

Join Date:
Jun 2005
Location:
Cumbria, UK
Posts:
10,327
Plugin Contributions:
0

Re: tpl_header.php how to set different logos for each language?

This is what I have done in the past...

The HEADER area also allows for a BACKGROUND IMAGE, which can be defined in the stylesheet:

#logoWrapper

So you could create your "logos" as a background images and add:


#logoWrapper {
background: #fff url(../images/logo-english.jpg) no-repeat left top;
}
... to a language stylesheet for ENGLISH (english_stylesheet.css)


#logoWrapper {
background: #fff url(../images/logo-french.jpg) no-repeat left top;
}
... to a language stylesheet for FRENCH (french_stylesheet.css)


#logoWrapper {
background: #fff url(../images/logo-spanish.jpg) no-repeat left top;
}
... to a language stylesheet for SPANISH (spanish_stylesheet.css)


THEN...

Just create a 1 pixel X 1 pixel transparent GIF for your logo.gif image (as it will no longer be needed as the actual logo, but is still needed as an image is "expected")

If you use JPG for your logo image, then choose a "neutral colour" for that single pixel, and save it as logo.jpg

If you use PNG, then you can do the same as for GIF, bu making the PNG transparent.

25 Mar 2013, 2:50 PM
#4
schoolboy avatar

schoolboy

Totally Zenned

Join Date:
Jun 2005
Location:
Cumbria, UK
Posts:
10,327
Plugin Contributions:
0

Re: tpl_header.php how to set different logos for each language?

Dr Byte's suggestion is preferable - but as he says... if your template has HARD CODED to image path, rather than using the DEFINE, you will have a problem.

25 Mar 2013, 10:11 PM
#5
ilmarchez avatar

ilmarchez

Zen Follower

Join Date:
Aug 2009
Posts:
128
Plugin Contributions:
0

Re: tpl_header.php how to set different logos for each language?

That worked perfectly, thank you very much!

DrByte:

Well, the original Zen Cart template contains language-dependent coding for the logo by calling HEADER_LOGO_IMAGE instead of 'images/logo.gif' specifically. Thus, your language files can contain the definition for HEADER_LOGO_IMAGE, and that way your template can be language-independent.

<div id="logo"><?php echo '<a href="' . HTTP_SERVER . DIR_WS_CATALOG . '">' . zen_image($template->get_template_dir(HEADER_LOGO_IMAGE, DIR_WS_TEMPLATE, $current_page_base,'images'). '/' . HEADER_LOGO_IMAGE, HEADER_ALT_TEXT) . '</a>'; ?></div>
> 
> Alternatively, if your template contains numerous additional very-language-specific components, you could have a separate template for each language, and simply enable those separate templates in your Admin->Tools->Template Select screen. But this is RARELY needed, and I usually only see people do this when supporting both RTL and LTR languages.