Jump to content

Tutorial: Add different logo for multi-language


Amir92

Recommended Posts

Hello, 

 

After reading different thread on How to add different logo for multiple languages, m trying to compile in single thread with complete answer.

 

Hope this will help someone, like me ;)

 

Let assume, you want to add two different logo for English and French language, create two different logo with name logo-en.jpg logo-fr.jpg

 

Step1: Add two logo image in img folder 

 

Step2: Update Database:

 

i) Open ps_configuration table, and search PS_LOGO in name column, copy id_configuration value. 

 

Only for Mobile: If you are using different logo for mobile then also copy id_configuration value for PS_LOGO_MOBILE ( by default, you will not find this value, as for web and mobile both are same, so no value in DB. You need to add above value if not available)

 

ii) Open ps_configuration_lang table and add logo details for different language,

 

Add two rows

 

id_configuration = same as ps_configuration table column id_configuration,

id_lang column = language id (Go to Localization>Languages and copy language id)

value = image name as "logo-en.jpg , logo-fr.jpg"

date_upd = leave as it is

 

Your final insert query will look similar to:

INSERT INTO `prestashop-db`.`ps_configuration_lang` (`id_configuration`, `id_lang`, `value`, `date_upd`) VALUES ('243', '1', 'logo-en.jpg', NULL);
INSERT INTO `prestashop-db`.`ps_configuration_lang` (`id_configuration`, `id_lang`, `value`, `date_upd`) VALUES ('243', '2', 'logo-fr.png', NULL);

Only for Mobile: Same query with id_configuration referring to ps_configuration table, PS_LOGO_MOBILE id_configuration column.

 

 

Step3: Update Controller class to read logo value from ps_configuration_lang table. 

 

Open classes/controller/FrontController.php

 

Update the lines

 

i) Update displayRestrictedCountryPage() method:

 

Line: 776:

protected function displayRestrictedCountryPage()
    {
        header('HTTP/1.1 503 temporarily overloaded');
        $this->context->smarty->assign(array(
            'shop_name'   => $this->context->shop->name,
            'favicon_url' => _PS_IMG_.Configuration::get('PS_FAVICON'),
//Update this line
            'logo_url'    => $this->context->link->getMediaLink(_PS_IMG_.Configuration::get('PS_LOGO'))

change it to:

    protected function displayRestrictedCountryPage()
    {
        header('HTTP/1.1 503 temporarily overloaded');
        $this->context->smarty->assign(array(
            'shop_name'   => $this->context->shop->name,
            'favicon_url' => _PS_IMG_.Configuration::get('PS_FAVICON'),
            //Pass id_lang parameter in Configuration::get('PS_LOGO')
            //$this->context->cookie->id_lang
            'logo_url'    => $this->context->link->getMediaLink(_PS_IMG_.Configuration::get('PS_LOGO',$this->context->cookie->id_lang))

ii) Update initLogoAndFavicon() method:

 

Line:1619

 public function initLogoAndFavicon()
    {
        $mobile_device = $this->context->getMobileDevice();       
        if ($mobile_device && Configuration::get('PS_LOGO_MOBILE')) {
 //Update this line, if you are using different logo for mobile device
            $logo = $this->context->link->getMediaLink(_PS_IMG_.Configuration::get('PS_LOGO_MOBILE').'?'.Configuration::get('PS_IMG_UPDATE_TIME'));
        } else {
//Update this line
            $logo = $this->context->link->getMediaLink(_PS_IMG_.Configuration::get('PS_LOGO'));
        }

 change it to:

    public function initLogoAndFavicon()
    {
        $mobile_device = $this->context->getMobileDevice();

        if ($mobile_device && Configuration::get('PS_LOGO_MOBILE')) {
//Pass id_lang parameter in Configuration::get('PS_LOGO')
//$this->context->cookie->id_lang
            $logo = $this->context->link->getMediaLink(_PS_IMG_.Configuration::get('PS_LOGO_MOBILE',$this->context->cookie->id_lang));
        } else {
//Pass id_lang parameter in Configuration::get('PS_LOGO')
//$this->context->cookie->id_lang
            $logo = $this->context->link->getMediaLink(_PS_IMG_.Configuration::get('PS_LOGO',$this->context->cookie->id_lang));
        }

Now, go to your browser, clear cache and refresh :)

 

If any issue, please reply in this thread. 

Edited by Amir92 (see edit history)
  • Like 2
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...