I have a view containing an unformatted list of fields. I want to create a specific template for the view. I have turned on Twig debug, but it suggests 'views_view_unformatted' for the file name, which would apply to all unformatted lists, but I want it specific to this view. What should be file name be?
I think the issue here is that Twig debug does not suggest all possible names.
Names containing the view display id or type are possible, but don't seem to be suggested by Twig debug.
The following are the possible template names sorted by precedence:
[base template name]--[view machine name]--[view display id].html.twig [base template name]--[view machine name]--[view display type].html.twig [base template name]--[view display type].html.twig [base template name]--[view machine name].html.twig [base template name].html.twig
To create template for view use following naming convention :
Use page if you are creating template for page view and block for block view
Hope this helps :)
I searched for a while till I finally found the solution in the Drupal API:
So the correct filename for your case would be:
views-view-unformatted--[view machine name]--[display].html
Like for example:
to be more precised with underscore and comma
- get the view machine name and display name from url
- then the template name would be
- for all display of type page for that view: