Skip to content

Instantly share code, notes, and snippets.

@csakiistvan
Created May 27, 2014 17:23
Show Gist options
  • Select an option

  • Save csakiistvan/7fbbc99b61dcfb3d90bd to your computer and use it in GitHub Desktop.

Select an option

Save csakiistvan/7fbbc99b61dcfb3d90bd to your computer and use it in GitHub Desktop.
Facebook like for multilanguage drupal website
<div class="fb-like" data-href="#" data-layout="standard" data-action="like" data-show-faces="false" data-share="true"></div>
<div id="fb-root"></div>
<script>(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/<?php print $facebook_language; ?>/all.js#xfbml=1";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
<?php
/**
* Override or insert variables into the html templates.
*
* @param $variables
* An array of variables to pass to the theme template.
* @param $hook
* The name of the template being rendered ("html" in this case.)
*/
function theme_preprocess_html(&$variables, $hook) {
$facebook_languages = array(
'en' => 'en_US',
'hu' => 'hu_HU',
);
$variables['facebook_language'] = $facebook_languages[$variables['language']->language];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment