1

I have a D8 subtheme of Bootstrap and on the homepage I have 2 Views (2 carousel views).

I turned on twig debugging so I could see which template file(s) is (are) being used, and where it starts and ends. When I used this before it included a listing of sample alternate filenames for that specific content (e.g. paragraph--about-us-page--full.html.twig), which was a big help.

For each of the views on the homepage, they are shown using views-view.html.twig and views-view-field.html.twig whether from the module template, bootstrap template or my copy of the files into my theme.

Is there a way to set up a template file for each of the views individually?

View Machine Names:

  • homepage_slider
  • homepage_loans

They only reside on the front page. I have tried renaming files to see if I can see it being used in the Twig debugging and frequently clear the cache.

It could be a Page, View, Block, etc. template, but then how do I reference the parts of the View to control the display of the fields.

Thank you.

1

I think what you're looking for is in this section: https://www.drupal.org/docs/theming-drupal/twig-in-drupal/twig-template-naming-conventions#s-views

Specifically,

views-view-field.html.twig based patterns are postfixed with the view's field id (as in replacement patterns) to display a single field in a view:

  • views-view-field--[viewid]--[view-display-id]--[fieldid].html.twig
  • views-view-field--[viewid]--page--[fieldid].html.twig
  • views-view-field--block--[fieldid].html.twig
  • views-view-field--[fieldid].html.twig
  • views-view-field.html.twig
1
  • This helped. The difficulty was finding the order to put everything and whether to separate with 2 "--" or 1 "-". It's still a work in progress but this let me take steps forward. I've also copied over all of the files being referenced in the debug output so I know which to modify and any that I don't touch I am going to delete and let bootstrap/module/core handle it. – Hometoy Apr 30 at 12:54
1

The reason you don't see these suggestions is due the the following bug, #2923634: Use hook_theme_suggestions in views

1
  • Thanks. This explains it now showing up so I worked around it. – Hometoy Apr 30 at 12:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.