You are here

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

Same filename and directory in other branches
  1. 8.4 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. {{ attach_library('views_bootstrap/components') }}
  23. <div id="{{ id }}" class="carousel slide" data-ride="carousel" data-interval="{{ interval }}" data-pause="{{ pause }}" data-wrap="{{ wrap }}">
  24. {# Carousel indicators #}
  25. {% if indicators %}
  26. <ol class="carousel-indicators">
  27. {% for key, row in rows %}
  28. {% set indicator_classes = [loop.first ? 'active'] %}
  29. <li class="{{ indicator_classes|join(' ') }}" data-target="#{{ id }}" data-slide-to="{{ key }}"></li>
  30. {% endfor %}
  31. </ol>
  32. {% endif %}
  33. {# Carousel rows #}
  34. <div class="carousel-inner" role="listbox">
  35. {% for row in rows %}
  36. {% set row_classes = ['item', loop.first ? 'active'] %}
  37. <div {{ row.attributes.addClass(row_classes) }}>
  38. {% if display == 'fields' %}
  39. {{ row.image }}
  40. {% if row.title or row.description %}
  41. <div class="carousel-caption">
  42. {% if row.title %}
  43. <h3>{{ row.title }}</h3>
  44. {% endif %}
  45. {% if row.description %}
  46. <p>{{ row.description }}</p>
  47. {% endif %}
  48. </div>
  49. {% endif %}
  50. {% else %}
  51. {{ row.content }}
  52. {% endif %}
  53. </div>
  54. {% endfor %}
  55. </div>
  56. {# Carousel navigation #}
  57. {% if navigation %}
  58. <a class="left carousel-control" href="#{{ id }}" role="button" data-slide="prev">
  59. <span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
  60. <span class="sr-only">{{ 'Previous'|t }}</span>
  61. </a>
  62. <a class="right carousel-control" href="#{{ id }}" role="button" data-slide="next">
  63. <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
  64. <span class="sr-only">{{ 'Next'|t }}</span>
  65. </a>
  66. {% endif %}
  67. </div>