Skip to main content
minor formatting and wording improvements
Source Link
berliner
  • 2.9k
  • 1
  • 21
  • 29

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.

You shouldn't need to add a theme suggestion if you're trying to override the view template for a given view ID. Confusing things 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 add 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[] = ... }

Hope that helps.

You shouldn't need to add a theme suggestion if you're trying to override the view template for a given view ID. The 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 adding 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[] = ...
}

Hope that helps.

Source Link
mikeker
  • 580
  • 2
  • 5

You shouldn't need to add a theme suggestion if you're trying to override the view template for a given view ID. Confusing things 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 add 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[] = ... }

Hope that helps.