You are here

views-view-flexbox.html.twig in Views Flexbox 8

Default theme implementation for views to display rows in a grid.

Available variables:

  • attributes: HTML attributes for the wrapping element.
  • title: The title of this group of rows.
  • view: The view object.
  • rows: The rendered view results.
  • options: The view plugin style options.
    • row_class_default: A flag indicating whether default classes should be used on rows.
    • col_class_default: A flag indicating whether default classes should be used on columns.
  • items: A list of grid items. Each item contains a list of rows or columns. The order in what comes first (row or column) depends on which alignment type is chosen (horizontal or vertical).

    • attributes: HTML attributes for each row or column.
    • content: A list of columns or rows. Each row or column contains:
      • attributes: HTML attributes for each row or column.
      • content: The row or column contents.

File

templates/views-view-flexbox.html.twig
View source
  1. {#
  2. /**
  3. * @file
  4. * Default theme implementation for views to display rows in a grid.
  5. *
  6. * Available variables:
  7. * - attributes: HTML attributes for the wrapping element.
  8. * - title: The title of this group of rows.
  9. * - view: The view object.
  10. * - rows: The rendered view results.
  11. * - options: The view plugin style options.
  12. * - row_class_default: A flag indicating whether default classes should be
  13. * used on rows.
  14. * - col_class_default: A flag indicating whether default classes should be
  15. * used on columns.
  16. * - items: A list of grid items. Each item contains a list of rows or columns.
  17. * The order in what comes first (row or column) depends on which alignment
  18. * type is chosen (horizontal or vertical).
  19. * - attributes: HTML attributes for each row or column.
  20. * - content: A list of columns or rows. Each row or column contains:
  21. * - attributes: HTML attributes for each row or column.
  22. * - content: The row or column contents.
  23. *
  24. * @see template_preprocess_views_view_grid()
  25. *
  26. * @ingroup themeable
  27. */
  28. #}
  29. {%
  30. set classes = [
  31. 'views-view-flexbox',
  32. 'views-flexbox-direction-' ~ options.direction,
  33. 'views-flexbox-justify-' ~ options.justify,
  34. 'views-flexbox-align-items-' ~ options.align_items,
  35. 'views-flexbox-align-content-' ~ options.align_content,
  36. ]
  37. %}
  38. {%
  39. set item_classes = [
  40. 'views-flexbox-item',
  41. ]
  42. %}
  43. {% if title %}
  44. <h3>{{ title }}</h3>
  45. {% endif %}
  46. <div{{ attributes.addClass(classes, options.style ? 'views-flexbox-' ~ options.style ) }}>
  47. {% for item in items %}
  48. {% if item.link %}
  49. <a{{ item.attributes.addClass(item_classes, options.item_class_default ? 'item-' ~ loop.index).setAttribute('href', item.link) }}>
  50. {% else %}
  51. <div{{ item.attributes.addClass(item_classes, options.item_class_default ? 'item-' ~ loop.index) }}>
  52. {% endif %}
  53. {{- item.content -}}
  54. {% if item.link %}
  55. </a>
  56. {% else %}
  57. </div>
  58. {% endif %}
  59. {% endfor %}
  60. </div>