You are here

function sharerich_node_view in Sharerich 7

Same name and namespace in other branches
  1. 7.3 sharerich.module \sharerich_node_view()
  2. 7.2 sharerich.module \sharerich_node_view()

Implements hook_node_view().

File

./sharerich.module, line 273

Code

function sharerich_node_view($node, $view_mode, $langcode) {
  $extra = sharerich_field_extra_fields();

  // Check that we're supporting the node type being viewed.
  if (empty($extra['node'][$node->type]['display'])) {
    return;
  }
  $config = field_bundle_settings('node', $node->type);
  foreach ($extra['node'][$node->type]['display'] as $field_name => $field_info) {

    // Check to make sure this field is visible in this view mode.
    $displays =& $config['extra_fields']['display'][$field_name];
    if (isset($displays['default']) && !isset($displays['full'])) {

      // Fallback for Default display when viewing full view node.
      $displays['full'] = $displays['default'];
    }
    if (isset($displays[$view_mode]) && $displays[$view_mode]['visible'] == FALSE) {
      continue;
    }
    if ($field_name == 'sharerich') {
      $node->content['sharerich'] = sharerich_get_buttons($node);
    }
  }
}