Closed (fixed)
Project:
Facebook Like Button
Version:
6.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Task
Assigned:
Reporter:
Created:
10 May 2011 at 13:07 UTC
Updated:
12 Jul 2011 at 13:51 UTC
Jump to comment: Most recent file
Hello,
Maybe this could be added to the code to be able to translate the facebook button language.
I have copied the modified code I've done.
/**
* Implementation of hook_form_alter().
*/
function fblikebutton_form_alter(&$form, &$form_state, $form_id){
if($form_id == "locale_languages_edit_form"){
$form['fblikebutton_language_code'] = array(
'#type' => 'textfield',
'#title' => t('Facebook Like Language Code'),
'#default_value' => variable_get('fblikebutton_locale_language_' . $form['langcode']['#value'], ''),
'#weight' => 0,
);
$form['#submit'][] = 'fblikebutton_locale_languages_edit_form_submit';
}
}
function fblikebutton_locale_languages_edit_form_submit($form, &$form_state) {
$values = $form_state['values'];
variable_set('fblikebutton_locale_language_' . $values['langcode'], $values['fblikebutton_language_code']);
}
/**
* Implementation of hook_nodeapi().
* @todo
* Add more config options for like button (size, etc).
*/
function fblikebutton_nodeapi(&$node, $op, $teaser, $page) {
global $user;
global $base_url;
global $language;
$lang = variable_get('fblikebutton_locale_language_' . $language->prefix, 'en');
$likebase = $base_url . '/';
$likepath = drupal_get_path_alias($_GET['q']);
$webpage_to_like = $likebase . $likepath;
switch ($op) {
case 'view':
// Set which node types users can "like".
$types_to_like = variable_get('fblikebutton_node_types', array('page'));
$show_faces = variable_get('fblikebutton_show_faces', 'true');
// Facebook is doing away with FBML, so we use the iframe plugin option instead.
$likebutton = '<iframe src="http://www.facebook.com/plugins/like.php?href=';
$likebutton .= urlencode($webpage_to_like);
$likebutton .= '&layout=standard&show_faces=';
$likebutton .= $show_faces;
$likebutton .= '&width=450&action=like&font&colorscheme=light&height=80&locale=' . $lang . '" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:80px;" allowTransparency="true"></iframe>';
// Keep the fblikebutton button out of search results, etc.
if (!$page) {
break;
}
// Do not add the like button to any of the unchecked node types.
if (!in_array($node->type, $types_to_like, TRUE)) {
break;
}
// Set permissions, and keep the button out of teasers. Otherwise, there
// would be 50 "like" buttons on the front page of some sites... Not good.
if (!$teaser && user_access('users may access Like button')) {
$node->content['fblikebutton_button'] = array(
'#value' => $likebutton,
'#weight' => 100,
);
}
break;
}
}
Hope this can help others.
Cheers
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | fblikebutton.module.txt | 11.67 KB | webadpro |
Comments
Comment #1
jerdiggity commentedOf course I see this *after* I made the last commit. :( My fault...
Thank you, though -- will look at it & add to next commit if all is OK.
:)
j
Comment #2
webadpro commentedSounds good!
Let me know if theres any issue with the code.
I haven't added the hook_uninstall in the install.php file, but in your commit I would recommend to add it. A simple loop through all the languages installed on the site to delete the variables of each language.
Also:
should be changed to:
Comment #3
webadpro commentedHi,
I have fixed number of bugs in the version and added translation possibility to the module including the block.
Cheers
Comment #4
jerdiggity commentedPlease see latest stable release. Thanks again!
:)
j
Comment #5
webadpro commentedGreat news!