function disqus_node_view in Disqus 7
Implements hook_node_view().
File
- ./
disqus.module, line 277 - The Disqus Drupal module.
Code
function disqus_node_view($node, $view_mode) {
if (isset($node->disqus) && user_access('view disqus comments') && $node->disqus['status'] == 1) {
switch ($view_mode) {
case 'full':
// Inject Disqus into the node object.
switch (variable_get('disqus_location', 'content_area')) {
case 'content_area':
// Inject into the node content.
$node->content['disqus'] = array(
'#type' => 'disqus',
'#disqus' => $node->disqus,
'#weight' => variable_get('disqus_weight', 50),
);
break;
}
break;
case 'teaser':
// Display the Disqus link.
$links['disqus_comments_num'] = array(
'title' => t('Comments'),
'href' => 'node/' . $node->nid,
'fragment' => 'disqus_thread',
'attributes' => array(
// Identify the node for Disqus with the unique identifier:
// http://docs.disqus.com/developers/universal/#comment-count
'data-disqus-identifier' => 'node/' . $node->nid,
),
);
$node->content['links']['disqus'] = array(
'#theme' => 'links',
'#links' => $links,
'#attributes' => array(
'class' => array(
'links',
'inline',
),
),
);
// Attach disqus.js to load the Disqus comment count JavaScript.
$node->content['links']['#attached']['js'][] = drupal_get_path('module', 'disqus') . '/js/disqus.js';
$node->content['links']['#attached']['js'][] = array(
'data' => array(
'disqusComments' => $node->disqus['domain'],
),
'type' => 'setting',
);
break;
}
}
else {
return array();
}
}