Issue #1209532 by timmillwood, lucascaro, wiifm, mikeytown2, slashrsm: Count node views via AJAX in the statistics module.
parent
da4adbdafb
commit
6a064f416a
|
@ -3,13 +3,11 @@
|
|||
"use strict";
|
||||
|
||||
$(document).ready(function() {
|
||||
var nid = Drupal.settings.statistics.nid;
|
||||
var basePath = Drupal.settings.basePath;
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
cache: false,
|
||||
url: basePath+"core/modules/statistics/statistics.php",
|
||||
data: "nid="+nid
|
||||
url: Drupal.settings.statistics.url,
|
||||
data: Drupal.settings.statistics.data
|
||||
});
|
||||
});
|
||||
})(jQuery);
|
||||
|
|
|
@ -102,9 +102,9 @@ function statistics_permission() {
|
|||
* Implements hook_node_view().
|
||||
*/
|
||||
function statistics_node_view(Node $node, $view_mode) {
|
||||
if (!empty($node->nid) && $view_mode == 'full') {
|
||||
if (!empty($node->nid) && $view_mode == 'full' && node_is_page($node) && empty($node->in_preview)) {
|
||||
$node->content['#attached']['library'][] = array('statistics', 'drupal.statistics');
|
||||
$settings = array('nid' => $node->nid);
|
||||
$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',
|
||||
|
|
Loading…
Reference in New Issue