statistics_node_view

statistics_node_view(array &$build, EntityInterface $node, EntityViewDisplayInterface $display, $view_mode)

Implements hook_ENTITY_TYPE_view() for node entities.

File

core/modules/statistics/statistics.module, line 40
Logs and displays content statistics for a site.

Code

function statistics_node_view(array &$build, EntityInterface $node, EntityViewDisplayInterface $display, $view_mode) {
  if (!$node->isNew() && $view_mode == 'full' && node_is_page($node) && empty($node->in_preview)) {
    $build['#attached']['library'][] = 'statistics/drupal.statistics';
    $settings = array('data' => array('nid' => $node->id()), 'url' => Url::fromUri('base:' . drupal_get_path('module', 'statistics') . '/statistics.php')->toString());
    $build['#attached']['drupalSettings']['statistics'] = $settings;
  }
}
doc_Drupal
2016-10-29 09:44:27
Comments
Leave a Comment

Please login to continue.