diff options
Diffstat (limited to 'modules/statistics/statistics.module')
-rw-r--r-- | modules/statistics/statistics.module | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/modules/statistics/statistics.module b/modules/statistics/statistics.module index 81d24b755..f665a14f2 100644 --- a/modules/statistics/statistics.module +++ b/modules/statistics/statistics.module @@ -57,7 +57,7 @@ function statistics_exit() { // in which case we need to bootstrap to the session phase anyway. drupal_bootstrap(DRUPAL_BOOTSTRAP_VARIABLES); - if (variable_get('statistics_count_content_views', 0)) { + if (variable_get('statistics_count_content_views', 0) && !variable_get('statistics_count_content_views_ajax', 0)) { // We are counting content views. if (arg(0) == 'node' && is_numeric(arg(1)) && arg(2) == NULL) { // A node has been viewed, so update the node's counters. @@ -115,6 +115,22 @@ function statistics_permission() { * Implements hook_node_view(). */ 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)) { + $node->content['#attached']['js'] = array( + drupal_get_path('module', 'statistics') . '/statistics.js' => 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); |