diff --git a/core/includes/theme.inc b/core/includes/theme.inc index 3ce3fcc..bf69cec 100644 --- a/core/includes/theme.inc +++ b/core/includes/theme.inc @@ -1036,9 +1036,9 @@ function theme($hook, $variables = array()) { $suggestions = array(); $suggestion_hooks = array( 'theme_suggestions', - 'theme_suggestions_' . $original_hook, + 'theme_suggestions_' . $hook, ); - // @todo Consider passing $original_hook as last argument. + // @todo Consider passing $hook as last argument like hook_form_alter() does. Drupal::moduleHandler()->alter($suggestion_hooks, $suggestions, $variables); // Check if each suggestion exists in the theme registry, and if so, diff --git a/core/modules/views/views.module b/core/modules/views/views.module index 3e61dc4..d94da83 100644 --- a/core/modules/views/views.module +++ b/core/modules/views/views.module @@ -237,9 +237,8 @@ function views_plugin_list() { */ function views_preprocess_node(&$vars) { Drupal::moduleHandler()->loadInclude('node', 'views.inc'); - // The 'view' attribute of the node is added in views_preprocess_node() - // @todo The comment above doesn't make any sense to me - it's saying the - // attribute is added in *this* function? + // The 'view' attribute of the node is added in + // \Drupal\views\Plugin\views\row\EntityRow::preRender(). if (!empty($vars['node']->view) && $vars['node']->view->storage->id()) { $vars['view'] = $vars['node']->view; // If a node is being rendered in a view, and the view does not have a path, @@ -259,11 +258,11 @@ function views_preprocess_node(&$vars) { * Implements hook_theme_suggestions_HOOK_alter(). */ function views_theme_suggestions_node_alter(&$suggestions, $variables) { - if (!empty($variables['node']->view) && $variables['node']->view->storage->id()) { - $variables['view'] = $variables['node']->view; - $suggestions[] = 'node__view__' . $variables['node']->view->storage->id(); - if (!empty($variables['node']->view->current_display)) { - $suggestions[] = 'node__view__' . $variables['node']->view->storage->id() . '__' . $variables['node']->view->current_display; + $node = $variables['elements']['#node']; + if (!empty($node->view) && $node->view->storage->id()) { + $suggestions[] = 'node__view__' . $node->view->storage->id(); + if (!empty($node->view->current_display)) { + $suggestions[] = 'node__view__' . $node->view->storage->id() . '__' . $node->view->current_display; } } } @@ -273,8 +272,8 @@ function views_theme_suggestions_node_alter(&$suggestions, $variables) { * templates if called from a view. */ function views_preprocess_comment(&$vars) { - // The 'view' attribute of the node is added in template_preprocess_views_view_row_comment() - // @todo I can't find the function mentioned in the above comment. + // The view data is added to the comment in + // \Drupal\views\Plugin\views\row\EntityRow::preRender(). if (!empty($vars['comment']->view) && $vars['comment']->view->storage->id()) { $vars['view'] = &$vars['comment']->view; } @@ -284,12 +283,11 @@ function views_preprocess_comment(&$vars) { * Implements hook_theme_suggestions_HOOK_alter(). */ function views_theme_suggestions_comment_alter(&$suggestions, $variables) { - if (!empty($variables['comment']->view) && $variables['comment']->view->storage->id()) { - $suggestions[] = 'comment__view__' . $variables['comment']->view->storage->id(); - // @todo Shouldn't the below be checking $variables['comment'] instead of - // $variables['node']? - if (!empty($variables['node']->view->current_display)) { - $suggestions[] = 'comment__view__' . $variables['comment']->view->storage->id() . '__' . $variables['comment']->view->current_display; + $comment = $variables['elements']['#comment']; + if (!empty($comment->view) && $comment->view->storage->id()) { + $suggestions[] = 'comment__view__' . $comment->view->storage->id(); + if (!empty($comment->view->current_display)) { + $suggestions[] = 'comment__view__' . $comment->view->storage->id() . '__' . $comment->view->current_display; } } }