You are here

function fblikebutton_node_view in Facebook Like Button 7.2

Same name and namespace in other branches
  1. 8 fblikebutton.module \fblikebutton_node_view()
  2. 7 fblikebutton.module \fblikebutton_node_view()

Implements of hook_node_view().

File

./fblikebutton.module, line 78
Adds Facebook's "Like" button to each selected node type. Adds a block with a global static value where users can "Like" the URL set by admins.

Code

function fblikebutton_node_view($node, $view_mode) {
  global $user, $base_url;
  $types = variable_get('fblikebutton_node_types', array());
  $fullnodedisplay = variable_get('fblikebutton_full_node_display', 0);
  $teaserdisplay = variable_get('fblikebutton_teaser_display', 0);
  $full = $view_mode == 'full' ? TRUE : FALSE;
  $show = !empty($types[$node->type]) && user_access('access fblikebutton');
  $webpage_to_like = url("node/{$node->nid}", array(
    'absolute' => TRUE,
  ));
  $likebutton_weight = variable_get('fblikebutton_weight', '0');
  $conf = fblikebutton_conf();
  if ($show) {

    // Content area
    if ($view_mode == 'teaser' && $teaserdisplay == 1 || $view_mode == 'full' && $fullnodedisplay == 0) {
      $node->content['fblikebutton_field'] = array(
        '#markup' => _fblikebutton_field($webpage_to_like, $conf),
        '#weight' => $likebutton_weight,
      );
    }

    // Link area
    if ($view_mode == 'teaser' && $teaserdisplay == 2 || $view_mode == 'full' && $fullnodedisplay == 2) {
      $node->content['links']['#links']['fblikebutton_field'] = array(
        'title' => _fblikebutton_field($webpage_to_like, $conf),
        'html' => TRUE,
      );
    }
  }
}