Skip to main content
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
removed tags from title
Link
avpaderno
  • 97.9k
  • 15
  • 164
  • 284

Drupal 8 Views Specific Field Tag Based Naming Conventionsfield tag based naming conventions (Overridingoverriding views-view-field.html.twig for specific fields)

Source Link

Drupal 8 Views Specific Field Tag Based Naming Conventions (Overriding views-view-field.html.twig for specific fields)

I've scoured the documentation and I simply cannot find an answer to this question regarding naming convention for twig files given a tagged view with the override of a specific field. Let me create a scenario to explain the problem.

Given Viewname with tag viewtag with a block display and a fieldname field.

I can override the theme as follows

Original file --> Overridden file name

  • views-view-unformatted.html.twig --> views-view-unformatted--viewtag.html.twig
  • views-view-field.html.twig --> views-view-field--fieldname.html.twig
  • views-view-field.html.twig --> views-view-field--viewname--block--fieldname.html.twig
  • views-view-field.html.twig --> views-view-field--block--fieldname.html.twig

I cannot figure out how to override views-view-field for a specific fieldname by specifying the viewtag. The following names do not work:

  • views-view-field--viewtag--fieldname
  • views-view-field--viewtag--block--fieldname
  • views-view-field--fieldname--viewtag
  • views-view-field--block--fieldname--viewtag
  • views-view-field--block--viewtag--fieldname

I've run out of possible combinations and yet I'm simply not able to get the viewtags to override the specific field. Surely there has to be a way to do this given that you can use the viewname to override the templates. I'd rather avoid having 50 versions of a view template when 1 could do the same thing.