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 .= '&amp;layout=standard&amp;show_faces=';
      $likebutton .= $show_faces;
      $likebutton .= '&amp;width=450&amp;action=like&amp;font&amp;colorscheme=light&amp;height=80&amp;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

CommentFileSizeAuthor
#3 fblikebutton.module.txt11.67 KBwebadpro

Comments

jerdiggity’s picture

Assigned: Unassigned » jerdiggity

Of 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

webadpro’s picture

Sounds 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:

$lang = variable_get('fblikebutton_locale_language_' . $language->prefix, 'en');

should be changed to:

$lang = variable_get('fblikebutton_locale_language_' . $language->language, 'en');
webadpro’s picture

StatusFileSize
new11.67 KB

Hi,

I have fixed number of bugs in the version and added translation possibility to the module including the block.

Cheers

jerdiggity’s picture

Status: Needs review » Fixed

Please see latest stable release. Thanks again!

:)

j

webadpro’s picture

Great news!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.