You are here

views-bootstrap-carousel.html.twig in Views Bootstrap 8.4

Same filename and directory in other branches
  1. 8.3 templates/views-bootstrap-carousel.html.twig

Default theme implementation for displaying a view as a bootstrap carousel.

Available variables:

  • view: The view object.
  • rows: A list of the view's row items.
  • id: A valid HTML ID and guaranteed to be unique.
  • interval: The amount of time to delay between automatically cycling a slide item. If false, carousel will not automatically cycle.
  • pause: Pauses the cycling of the carousel on mouseenter and resumes the cycling of the carousel on mouseleave.
  • wrap: Whether the carousel should cycle continuously or have hard stops.

File

templates/views-bootstrap-carousel.html.twig
View source
  1. {#
  2. /**
  3. * @file
  4. * Default theme implementation for displaying a view as a bootstrap carousel.
  5. *
  6. * Available variables:
  7. * - view: The view object.
  8. * - rows: A list of the view's row items.
  9. * - id: A valid HTML ID and guaranteed to be unique.
  10. * - interval: The amount of time to delay between automatically cycling a
  11. * slide item. If false, carousel will not automatically cycle.
  12. * - pause: Pauses the cycling of the carousel on mouseenter and
  13. * resumes the cycling of the carousel on mouseleave.
  14. * - wrap: Whether the carousel should cycle continuously or have
  15. * hard stops.
  16. *
  17. * @see template_preprocess_views_bootstrap_carousel()
  18. *
  19. * @ingroup themeable
  20. */
  21. #}
  22. <div id="{{ id }}" class="carousel {{ effect }}"
  23. data-interval="{{ interval }}"
  24. {% if ride %} data-ride="carousel" {% endif %}
  25. data-pause="{% if pause %}hover{% else %}false{% endif %}"
  26. >
  27. {# Show indicators if set in view. #}
  28. {% if indicators %}
  29. <ol class="carousel-indicators">
  30. {% for key, row in rows %}
  31. {% set indicator_classes = [loop.first ? 'active'] %}
  32. <li class="{{ indicator_classes|join(' ') }}" data-target="#{{ id }}" data-slide-to="{{ key }}"></li>
  33. {% endfor %}
  34. </ol>
  35. {% endif %}
  36. {# Carousel body. #}
  37. <div class="carousel-inner">
  38. {% for row in rows %}
  39. {% set row_classes = ['carousel-item', loop.first ? 'active'] %}
  40. <div class="{{ row_classes|join(' ') }}">
  41. {{ row.image }}
  42. {% if row.title or row.description %}
  43. {% if use_caption %}
  44. <div class="carousel-caption d-none d-md-block">
  45. {% endif %}
  46. {% if row.title %}
  47. <h3>{{ row.title }}</h3>
  48. {% endif %}
  49. {% if row.description %}
  50. <p>{{ row.description }}</p>
  51. {% endif %}
  52. {% if use_caption %}
  53. </div>
  54. {% endif %}
  55. {% endif %}
  56. </div>
  57. {% endfor %}
  58. </div>
  59. {# Controls #}
  60. {% if navigation %}
  61. <a class="carousel-control-prev" href="#{{ id }}" role="button" data-slide="prev">
  62. <span class="carousel-control-prev-icon" aria-hidden="true"></span>
  63. <span class="sr-only">{{ 'Previous'|t }}</span>
  64. </a>
  65. <a class="carousel-control-next" href="#{{ id }}" role="button" data-slide="next">
  66. <span class="carousel-control-next-icon" aria-hidden="true"></span>
  67. <span class="sr-only">{{ 'Next'|t }}</span>
  68. </a>
  69. {% endif %}
  70. </div>