Does theme_suggestions_views_view_alter work with views in Drupal 8.x.3? I have cleared the cache(drush cr) multiple times to try and get it to work. After a search on the web, I can't seem to find any information on this subject and wondering is this a bug or it can't be done.

  1. Image Selection_004.jpg shows that suggestions exist in debugging.
  2. Image Selection_008.jpg is the twig file that I have created in my theme.

This is the function I have been trying to get to work.

/**
 * Implements hook_theme_suggestions_HOOK_alter() for form templates.
 *
 * @param array $suggestions
 * @param array $variables
 */
function purencool_vision_theme_suggestions_views_view_alter(array &$suggestions, array $variables) {

  if (isset($variables['view'])) {
    $view_id = $variables['view']->id();
    $view_block = $variables['view']->getDisplay()->display['id'];
    array_splice($suggestions, 1, 0, 'view__' . $view_id . '__' . $view_block);
  }
}
Files: 
CommentFileSizeAuthor
Selection_008.jpg144.84 KBPurencool
Selection_004.jpg23.36 KBPurencool

Comments

Purencool created an issue. See original summary.

Purencool’s picture

Issue summary: View changes