You are here

function fb_example_node_view in Drupal for Facebook 7.3

Implements hook_node_view().

File

contrib/fb_example.module, line 150
Example customizations to modules/fb.

Code

function fb_example_node_view($node, $view_mode = 'full') {

  // This is an example of how you might add a 'like' button to the node links.
  if (variable_get('fb_example_link_add_like', TRUE)) {

    // Switch to control this behavior.
    $url = fb_scrub_urls(url('node/' . $node->nid, array(
      'absolute' => TRUE,
    )));
    $node->content['links']['node']['#links']['fb_like'] = array(
      'title' => "<fb:like layout='button_count' href={$url}></fb:like>",
      'html' => TRUE,
    );
  }

  // This is an example of how you might add a 'like' button into the content area.
  if (variable_get('fb_example_nodeapi_add_like', TRUE)) {
    $url = fb_scrub_urls(url('node/' . $node->nid, array(
      'absolute' => TRUE,
    )));
    $node->content['fb_like'] = array(
      '#markup' => "<fb:like href={$url}></fb:like>",
      '#weight' => -10,
      '#prefix' => '<div class="fb_like_wrapper">',
      '#suffix' => '</div>',
    );
  }
}