function statistics_node_view
Same name in other branches
- 9 core/modules/statistics/statistics.module \statistics_node_view()
- 8.9.x core/modules/statistics/statistics.module \statistics_node_view()
- 10 core/modules/statistics/statistics.module \statistics_node_view()
- 11.x core/modules/statistics/statistics.module \statistics_node_view()
Implements hook_node_view().
File
-
modules/
statistics/ statistics.module, line 115
Code
function statistics_node_view($node, $view_mode) {
// Attach Ajax node count statistics if configured.
if (variable_get('statistics_count_content_views', 0) && variable_get('statistics_count_content_views_ajax', 0)) {
if (!empty($node->nid) && $view_mode == 'full' && node_is_page($node) && empty($node->in_preview)) {
$statistics = drupal_get_path('module', 'statistics') . '/statistics.js';
$node->content['#attached']['js'][$statistics] = array(
'scope' => 'footer',
);
$settings = array(
'data' => array(
'nid' => $node->nid,
),
'url' => url(drupal_get_path('module', 'statistics') . '/statistics.php'),
);
$node->content['#attached']['js'][] = array(
'data' => array(
'statistics' => $settings,
),
'type' => 'setting',
);
}
}
if ($view_mode != 'rss') {
if (user_access('view post access counter')) {
$statistics = statistics_get($node->nid);
if ($statistics) {
$links['statistics_counter']['title'] = format_plural($statistics['totalcount'], '1 read', '@count reads');
$node->content['links']['statistics'] = array(
'#theme' => 'links__node__statistics',
'#links' => $links,
'#attributes' => array(
'class' => array(
'links',
'inline',
),
),
);
}
}
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.