Modifying Prestashop Languages for Facebook Page Plugin Module

Prestashop 1.6 Facebook Page plugin module present in default theme is outdated one. Facebook already changed its social plugin code. So I wanted to update it with their new “responsive” feature and to fir it in whole module’s area in default theme, which has 330px width, and Facebook wasn’t filling it from side to side. I also wanted to have Facebook widget to display in a current user’s language available on my shop.

So first we should modify this module and to make sure it doesn’t changes on Prestashop’s next update. I’ll put blockfacebook.tpl into my theme > modules > blockfacebook, if it’s not present there yet. And will add whole code generated on fb page social plugin page into this .tpl file, changing actual URL address with {$facebookurl|escape:'html':'UTF-8'} as it was before.

Now we need to disable javascript file provided with the module, as we already put a new javascript on .tpl file. We could add an empty .js file into my theme > js > modules > blockfacebook, or we could copy blockfacebook.php page into my theme’s modules too (my theme > modules > blockfacebook) and to disable both 2 mentions of blockfacebook.js so the module will not add an unnecessary file to the shop’s code.

Change Language of Facebook Page Social Plugin

Now when we have JavaScript code inside our .tpl we could modify language of Facebook script based on page’s actual language displayed to the site’s user.

We have this link inside FB JavaScript code, // which is setting plugin’s language. Here we should change the en_US code according to page’s language. To do so, we’ll change the code, according to Smarty rules:

//{if $lang_iso == 'he'}he_IL{elseif $lang_iso == 'ru'}ru_RU{else}en_US{/if}/sdk.js#xfbml=1&version=v2.5&appId=xxxxxxx

Change language codes according to your shop’s available languages, to your fb appId and changing languages on fb social page plugins you can examine right codes for languages of fb widget. Make sure codes are set right and without spaces.

Now Facebook widget will display with shop’s selected language. Same thing could be done for i.e. Google Plus etc., but I think for Google+ just inserting $lang_iso would be enough, as it is using only 2-letters code.

This entry was posted in PrestaShop and tagged . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *