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";
|
"use strict";
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
var nid = Drupal.settings.statistics.nid;
|
|
||||||
var basePath = Drupal.settings.basePath;
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: "POST",
|
type: "POST",
|
||||||
cache: false,
|
cache: false,
|
||||||
url: basePath+"core/modules/statistics/statistics.php",
|
url: Drupal.settings.statistics.url,
|
||||||
data: "nid="+nid
|
data: Drupal.settings.statistics.data
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
})(jQuery);
|
})(jQuery);
|
||||||
|
|
|
@ -102,9 +102,9 @@ function statistics_permission() {
|
||||||
* Implements hook_node_view().
|
* Implements hook_node_view().
|
||||||
*/
|
*/
|
||||||
function statistics_node_view(Node $node, $view_mode) {
|
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');
|
$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(
|
$node->content['#attached']['js'][] = array(
|
||||||
'data' => array('statistics' => $settings),
|
'data' => array('statistics' => $settings),
|
||||||
'type' => 'setting',
|
'type' => 'setting',
|
||||||
|
|
Loading…
Reference in New Issue