You are here

function easy_social_node_view in Easy Social 7.2

Same name and namespace in other branches
  1. 7 easy_social.module \easy_social_node_view()

Implements hook_node_view().

File

./easy_social.module, line 501
Easy social module.

Code

function easy_social_node_view($node, $view_mode, $langcode) {

  // We use this instead of $node->path to get an absolute URL.
  $url = url('node/' . $node->nid, array(
    'absolute' => TRUE,
  ));

  // Check if Easy Social is enabled for this content type.
  if (variable_get_value("easy_social_{$node->type}_enable")) {
    $type = variable_get_value("easy_social_{$node->type}_type");
    $enabled_widgets = variable_get_value("easy_social_{$node->type}_widgets");
    $widgets = _easy_social_render_widgets($url, $node->title, $type, $enabled_widgets, $node->language);
    $count = variable_get_value("easy_social_{$node->type}_count");

    // Add as many extra fields as we've defined.
    for ($i = 1; $i <= $count; ++$i) {
      $node->content["easy_social_{$i}"] = array(
        '#theme' => 'easy_social_links',
        '#widgets' => $widgets,
        '#widget_type' => $type,
        '#lang' => $node->language,
        '#weight' => 100 + $i,
      );
    }
  }
}