You are here

gridstack-box.html.twig in GridStack 8.2

Same filename and directory in other branches
  1. 8 templates/gridstack-box.html.twig

Default theme implementation for the individual GridStack box/item template.

Available variables:

  • attributes: An array of attributes to apply to the element.
  • item.box: A renderable array of the main image/background, or empty if CSS background image is preferred.
  • item.caption: A renderable array containing caption fields if provided:
    • title: The individual box title.
    • link: The box links or buttons.
    • data: any possible field for more complex data if crazy enough.
  • settings: An array containing the given settings.

File

templates/gridstack-box.html.twig
View source
  1. {#
  2. /**
  3. * @file
  4. * Default theme implementation for the individual GridStack box/item template.
  5. *
  6. * Available variables:
  7. * - attributes: An array of attributes to apply to the element.
  8. * - item.box: A renderable array of the main image/background, or empty if
  9. * CSS background image is preferred.
  10. * - item.caption: A renderable array containing caption fields if provided:
  11. * - title: The individual box title.
  12. * - link: The box links or buttons.
  13. * - data: any possible field for more complex data if crazy enough.
  14. * - settings: An array containing the given settings.
  15. *
  16. * @see template_preprocess_gridstack_box()
  17. */
  18. #}
  19. {%
  20. set classes = [
  21. settings.layout ? 'box--caption--' ~ settings.layout|clean_class,
  22. settings.empty ? 'box--empty',
  23. ]
  24. %}
  25. {%
  26. set caption_classes = [
  27. 'box__caption',
  28. ]
  29. %}
  30. <{{ wrapper }}{{ attributes.addClass(classes) }}>
  31. {# Allows background mode only, or prefacing content for layering to work. #}
  32. {{ item.preface }}
  33. {% if settings.use_inner %}
  34. <div{{ content_attributes }}>
  35. {% endif %}
  36. {{ item.box }}
  37. {% if item.caption %}
  38. <div{{ caption_attributes.addClass(caption_classes) }}>
  39. {% if item.caption.title %}
  40. <h2 class="box__title">{{ item.caption.title }}</h2>
  41. {% endif %}
  42. {% if item.caption.data or item.caption.alt %}
  43. <div class="box__description">
  44. {{ item.caption.data }}
  45. {{ item.caption.alt }}
  46. </div>
  47. {% endif %}
  48. {% if item.caption.link %}
  49. <div class="box__link">{{ item.caption.link }}</div>
  50. {% endif %}
  51. </div>
  52. {% if item.caption.category %}
  53. <div class="box__category">{{ item.caption.category }}</div>
  54. {% endif %}
  55. {% endif %}
  56. {% if settings.use_inner %}
  57. </div>
  58. {% endif %}
  59. </{{ wrapper }}>