1

I have created a view for content type = "Article" and have chosen "FORMAT" = GRID

FORMAT

Format:Grid | Settings

Show:Fields | Settings

My question is where does this view related template get saved?

I know Views default templates are located under "/core/modules/views/templates/" folder.

Here is the basic GRID template. How this grid template recognize a specific view that can render fields only of "ARTICLE" content type?

Is there any other template formed using view's machine name and row style?

Where should I place any view template so that it can effect all views of specific content type like "Article".

0

Where should I place any view template so that it can effect all views of specific content type like "Article".

While you can do this with nodes, I don't believe it's possible on views to affect all views of x content type. As you can see in FILTERS, there is a Type filter (=Article). It's just a filter.

The best option you have is to make it affect a specific view name and a view display.

EX: views-view-grid--[view-name].html.twig

if you want to specify a display then views-view-grid--[view-name]--[machine-name].html.twig

Then you copy the code from core's views-view-grid.html and paste it on your template file and modify as you wish.

If you want to alter fields, then use views-view-fields--[view-name]--[machine-name].html.twig

You place your custom template files in /themes/[Your Theme]/templates folder.

  • And where should I place this file? I mean in which folder should I put it? – Sugandh Khanna Jul 21 '16 at 8:58
  • @SugandhKhanna goes inside your theme's templates folder – No Sssweat Jul 21 '16 at 9:02
  • Will it work if I place this twig template file inside my custom module with proper naming conventions? – Sugandh Khanna Jul 21 '16 at 9:05
  • @SugandhKhanna it won't. For module, you might be able to do it using hook_theme_suggestions_HOOK_alter() Here is an article on how to create a template for a view filter might help you figure out how to do it for the actual view. – No Sssweat Jul 21 '16 at 9:18

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.