views-view-field.html.twig

Default theme implementation for a single field in a view.

It is not actually used in default views, as this is registered as a theme function which has better performance. For single overrides, the template is perfectly okay.

Available variables:

  • view: The view that the field belongs to.
  • field: The field handler that can process the input.
  • row: The raw result of the database query that generated this field.
  • output: The processed output that will normally be used.

When fetching output from the row this construct should be used: data = row[field.field_alias]

The above will guarantee that you'll always get the correct data, regardless of any changes in the aliasing that might happen if the view is modified.

See also

template_preprocess()

template_preprocess_views_view_field()

File

drupal/core/modules/views/templates/views-view-field.html.twig
View source
  1. {#
  2. /**
  3. * @file
  4. * Default theme implementation for a single field in a view.
  5. *
  6. * It is not actually used in default views, as this is registered as a theme
  7. * function which has better performance. For single overrides, the template is
  8. * perfectly okay.
  9. *
  10. * Available variables:
  11. * - view: The view that the field belongs to.
  12. * - field: The field handler that can process the input.
  13. * - row: The raw result of the database query that generated this field.
  14. * - output: The processed output that will normally be used.
  15. *
  16. * When fetching output from the row this construct should be used:
  17. * data = row[field.field_alias]
  18. *
  19. * The above will guarantee that you'll always get the correct data, regardless
  20. * of any changes in the aliasing that might happen if the view is modified.
  21. *
  22. * @see template_preprocess()
  23. * @see template_preprocess_views_view_field()
  24. *
  25. * @ingroup themeable
  26. */
  27. #}
  28. {{ output }}

Related topics