Skip to content
Snippets Groups Projects
Commit 57cf7f08 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #2191543 by tim.plunkett: Fixed history_node_view_alter() overwrite all #attached on nodes.

parent d29ed30e
No related branches found
No related tags found
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
...@@ -135,20 +135,14 @@ function history_cron() { ...@@ -135,20 +135,14 @@ function history_cron() {
function history_node_view_alter(array &$build, EntityInterface $node, EntityViewDisplayInterface $display) { function history_node_view_alter(array &$build, EntityInterface $node, EntityViewDisplayInterface $display) {
// Update the history table, stating that this user viewed this node. // Update the history table, stating that this user viewed this node.
if (($display->originalMode === 'full') && \Drupal::currentUser()->isAuthenticated()) { if (($display->originalMode === 'full') && \Drupal::currentUser()->isAuthenticated()) {
$build['#attached'] = array( // When the window's "load" event is triggered, mark the node as read.
'js' => array( // This still allows for Drupal behaviors (which are triggered on the
// When the window's "load" event is triggered, mark the node as read. // "DOMContentReady" event) to add "new" and "updated" indicators.
// This still allows for Drupal behaviors (which are triggered on the $build['#attached']['js'][] = array(
// "DOMContentReady" event) to add "new" and "updated" indicators. 'data' => 'window.addEventListener("load",function(){Drupal.history.markAsRead(' . $node->id() . ');},false);',
array( 'type' => 'inline',
'data' => 'window.addEventListener("load",function(){Drupal.history.markAsRead(' . $node->id() . ');},false);',
'type' => 'inline',
),
),
'library' => array(
'history/drupal.history',
),
); );
$build['#attached']['library'][] = 'history/drupal.history';
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment