You shouldn't need to add a theme suggestion if you're trying to override the view template for a given view ID. Confusing thingsThe confusing thing is the fact that Views' suggestions don't show in the debug code (see: https://www.drupal.org/node/2118743).
If you add a file named views-view--view-machine-name.html.twig
(replacing machine-name
, of course) in your theme's templates
directory and clear caches, it should pick it up. Note: it has to be templates
and not in your theme's root or my_templates
or anything else. Drupal is picky that way.
You should not need to worry about module/theme weights as all module alter functions run before theme alter functions.
Finally, if you are addadding theme suggestions, I would recommend using the more targeted hook_theme_suggestions_HOOK_alter
. (For views, the HOOK is views-view
so your function would look like:
function mytheme_theme_suggestions_views_view_alter(array &$suggestions, array $variables) { $suggestions[] = ... }
function mytheme_theme_suggestions_views_view_alter(array &$suggestions, array $variables) {
$suggestions[] = ...
}
Hope that helps.