You are here

fotorama-gallery-field.html.twig in Fotorama Gallery 8.2

Same filename and directory in other branches
  1. 8 templates/fotorama-gallery-field.html.twig

Default theme implementation for a fotorama gallery field.

To override output, copy the "fotorama-gallery-field.html.twig" from the templates directory to your theme's directory and customize it, just like customizing other Drupal templates such as page.html.twig or node.html.twig.

Instead of overriding the theming for all fields, you can also just override theming for a subset of fields using Theme hook suggestions. For example, here are some theme hook suggestions that can be used for a field_foo with format fotorama gallery on an article node type:

  • fotorama-gallery-field--node--field-foo--article.html.twig
  • fotorama-gallery-field--node--field-foo.html.twig
  • fotorama-gallery-field--node--article.html.twig
  • fotorama-gallery-field--field-foo.html.twig
  • fotorama-gallery-field--text-with-summary.html.twig
  • fotorama-gallery-field.html.twig

Available variables:

  • attributes: HTML attributes for the containing element.
  • label_hidden: Whether to show the field label or not.
  • title_attributes: HTML attributes for the title.
  • label: The label for the field.
  • multiple: TRUE if a field can contain multiple items.
  • items: List of all the field items. Each item contains:
    • attributes: List of HTML attributes for each item.
    • content: The field item's content.

File

templates/fotorama-gallery-field.html.twig
View source
  1. {#
  2. /**
  3. * @file
  4. * Default theme implementation for a fotorama gallery field.
  5. *
  6. * To override output, copy the "fotorama-gallery-field.html.twig" from the templates directory
  7. * to your theme's directory and customize it, just like customizing other
  8. * Drupal templates such as page.html.twig or node.html.twig.
  9. *
  10. * Instead of overriding the theming for all fields, you can also just override
  11. * theming for a subset of fields using
  12. * @link themeable Theme hook suggestions. @endlink For example,
  13. * here are some theme hook suggestions that can be used for a field_foo with format fotorama gallery
  14. * on an article node type:
  15. * - fotorama-gallery-field--node--field-foo--article.html.twig
  16. * - fotorama-gallery-field--node--field-foo.html.twig
  17. * - fotorama-gallery-field--node--article.html.twig
  18. * - fotorama-gallery-field--field-foo.html.twig
  19. * - fotorama-gallery-field--text-with-summary.html.twig
  20. * - fotorama-gallery-field.html.twig
  21. *
  22. * Available variables:
  23. * - attributes: HTML attributes for the containing element.
  24. * - label_hidden: Whether to show the field label or not.
  25. * - title_attributes: HTML attributes for the title.
  26. * - label: The label for the field.
  27. * - multiple: TRUE if a field can contain multiple items.
  28. * - items: List of all the field items. Each item contains:
  29. * - attributes: List of HTML attributes for each item.
  30. * - content: The field item's content.
  31. *
  32. * @see template_preprocess_fotorama_gallery_field()
  33. *
  34. * @ingroup themeable
  35. */
  36. #}
  37. {{ attach_library('fotorama_gallery/fotorama') }}
  38. {% if label_hidden %}
  39. {% if multiple %}
  40. <div{{ attributes.addClass('fotorama') }}>
  41. {% for item in items %}
  42. {{ item.content }}
  43. {% endfor %}
  44. </div>
  45. {% else %}
  46. {% for item in items %}
  47. {{ item.content }}
  48. {% endfor %}
  49. {% endif %}
  50. {% else %}
  51. <div>
  52. <div{{ title_attributes }}>{{ label }}</div>
  53. {% if multiple %}
  54. <div {{ attributes.addClass('fotorama') }}>
  55. {% endif %}
  56. {% for item in items %}
  57. {{ item.content }}
  58. {% endfor %}
  59. {% if multiple %}
  60. </div>
  61. {% endif %}
  62. </div>
  63. {% endif %}