You are here

function discussthis_node_view in Discuss This! 7.2

Same name and namespace in other branches
  1. 7 discussthis.node.inc \discussthis_node_view()

Implements hook_node_view().

File

./discussthis.node.inc, line 12
File with node discussion display methods.

Code

function discussthis_node_view($node, $view_mode, $langcode) {
  global $user;
  if ($node) {
    $links = array();

    // Verify that the content type is eligible for discussion.
    $node_types = node_type_get_names();
    $discussthis_types_config = variable_get('discussthis_types_config', array());
    if (!isset($discussthis_types_config[$node->type][$node->type . '_enable']) || !$discussthis_types_config[$node->type][$node->type . '_enable']) {
      return $links;
    }

    // Lookup for topic nid, if it exists (otherwise we get 0).
    $topic_nid = _discussthis_get_topic($node->nid);

    // Only pages being displayed full page have comments shown.
    if ($view_mode == 'full' && $topic_nid) {
      $node->content['discussion'] = _discussthis_discussion_load($topic_nid);
      $node->content['discussion']['#weight'] = $node->content['body']['#weight'] + 100;
    }
  }
}