You are here

paragraph--bp-carousel.html.twig in Varbase Bootstrap Paragraphs 8.7

Bootstrap Paragraphs template for displaying a Carousel.

Available variables:

  • paragraph: Full paragraph entity.

    • id: The paragraph ID.
    • bundle: The type of the paragraph, for example, "image" or "text".
    • authorid: The user ID of the paragraph author.
    • createdtime: Formatted creation date. Preprocess functions can reformat it by calling format_date() with the desired parameters on $variables['paragraph']->getCreatedTime().
  • content: All paragraph items. Use {{ content }} to print them all, or print a subset such as {{ content.field_example }}. Use {{ content|without('field_example') }} to temporarily suppress the printing of a given child element.
  • attributes: HTML attributes for the containing element. The attributes.class element may contain one or more of the following classes:

    • paragraphs: The current template type (also known as a "theming hook").
    • paragraphs--type-[type]: The current paragraphs type. For example, if the paragraph is an "Image" it would result in "paragraphs--type--image". Note that the machine name will often be in a short form of the human readable label.
    • paragraphs--view-mode--[view_mode]: The View Mode of the paragraph; for example, a preview would result in: "paragraphs--view-mode--preview", and default: "paragraphs--view-mode--default".
  • view_mode: View mode; for example, "preview" or "full".
  • logged_in: Flag for authenticated user status. Will be true when the current user is a logged-in member.
  • is_admin: Flag for admin user status. Will be true when the current user is an administrator.

File

templates/paragraph--bp-carousel.html.twig
View source
  1. {#
  2. /**
  3. * @file
  4. * Bootstrap Paragraphs template for displaying a Carousel.
  5. *
  6. * Available variables:
  7. * - paragraph: Full paragraph entity.
  8. * - id: The paragraph ID.
  9. * - bundle: The type of the paragraph, for example, "image" or "text".
  10. * - authorid: The user ID of the paragraph author.
  11. * - createdtime: Formatted creation date. Preprocess functions can
  12. * reformat it by calling format_date() with the desired parameters on
  13. * $variables['paragraph']->getCreatedTime().
  14. * - content: All paragraph items. Use {{ content }} to print them all,
  15. * or print a subset such as {{ content.field_example }}. Use
  16. * {{ content|without('field_example') }} to temporarily suppress the printing
  17. * of a given child element.
  18. * - attributes: HTML attributes for the containing element.
  19. * The attributes.class element may contain one or more of the following
  20. * classes:
  21. * - paragraphs: The current template type (also known as a "theming hook").
  22. * - paragraphs--type-[type]: The current paragraphs type. For example, if the paragraph is an
  23. * "Image" it would result in "paragraphs--type--image". Note that the machine
  24. * name will often be in a short form of the human readable label.
  25. * - paragraphs--view-mode--[view_mode]: The View Mode of the paragraph; for example, a
  26. * preview would result in: "paragraphs--view-mode--preview", and
  27. * default: "paragraphs--view-mode--default".
  28. * - view_mode: View mode; for example, "preview" or "full".
  29. * - logged_in: Flag for authenticated user status. Will be true when the
  30. * current user is a logged-in member.
  31. * - is_admin: Flag for admin user status. Will be true when the current user
  32. * is an administrator.
  33. *
  34. * @see template_preprocess_paragraph()
  35. *
  36. * @ingroup themeable
  37. */
  38. #}
  39. {{ attach_library('varbase_bootstrap_paragraphs/vbp-default') }}
  40. {{ attach_library('varbase_bootstrap_paragraphs/vbp-colors') }}
  41. {{ attach_library('varbase_bootstrap_paragraphs/vbp-carousel') }}
  42. {# Background color. #}
  43. {% if content.bp_background|render %}
  44. {% set layout_background = content.bp_background['#items'].getString() %}
  45. {% set layout_background_classes = [ layout_background ] %}
  46. {% endif %}
  47. {# Renders Slide Interval field. #}
  48. {# Converts database values to classes supplied by template. #}
  49. {% if content.bp_slide_interval|render %}
  50. {% set slide_interval = content.bp_slide_interval['#items'].getString() %}
  51. {% set slide_interval_classes = [ slide_interval ] %}
  52. {% endif %}
  53. {# The template default set classes. #}
  54. {%
  55. set classes = [
  56. 'paragraph',
  57. 'paragraph--type--' ~ paragraph.bundle|clean_class,
  58. view_mode ? 'paragraph--view-mode--' ~ view_mode|clean_class,
  59. 'carousel',
  60. 'slide',
  61. ]
  62. %}
  63. {# Merges Background color with classes. #}
  64. {% set background_field = content.bp_background|render %}
  65. {% if background_field %}
  66. {% set classes = classes|merge(layout_background_classes) %}
  67. {% endif %}
  68. {# No container by default. #}
  69. {% set add_container = false %}
  70. {# If there is BG image it's always edge to edge #}
  71. {% if (VBP.background_image.url or content.bp_background|render) %}
  72. {% set attributes = attributes.addClass('bg-edge2edge') %}
  73. {% set add_container = true %}
  74. {% endif %}
  75. {# If gutter option were selected. #}
  76. {% if VBP.bp_gutter.value %}
  77. {% set add_container = true %}
  78. {% endif %}
  79. {# Sets Unique ID for Carousel from Paragraph ID. #}
  80. {% set paragraph_id = 'vbp-carousel-' ~ paragraph.id.value %}
  81. {# Sets paragraph title for paragraph. #}
  82. {% set paragraph_title = content.bp_title[0]['#context']['value']|render %}
  83. {# Sets paragraph title status for paragraph. #}
  84. {% set paragraph_title_status = true %}
  85. {% if VBP.bp_title_status.value %}
  86. {% set paragraph_title_status = false %}
  87. {% endif %}
  88. {# Add custom paragraph CSS class(es). #}
  89. {% if VBP.bp_classes.value %}
  90. {% set striped_custom_classes = VBP.bp_classes.value|striptags|lower %}
  91. {% set split_custom_classes = striped_custom_classes|split(' ') %}
  92. {% for custom_class in split_custom_classes %}
  93. {% set clened_custom_class = [ custom_class|clean_class ] %}
  94. {% set classes = classes|merge(clened_custom_class) %}
  95. {% endfor %}
  96. {% endif %}
  97. {# Prints Carousel template. #}
  98. {{ content|without('bp_title', 'bp_title_status', 'bp_slide_content','bp_slide_interval', 'bp_width', 'bp_background', 'bp_classes', 'bp_gutter') }}
  99. <div{{ attributes.addClass(classes).setAttribute('id', paragraph_id).setAttribute('data-interval', slide_interval_classes).setAttribute('data-ride', 'carousel') }} {% if VBP.background_image.url %} style="background-image:url({{- VBP.background_image.url -}});" {% endif %}>
  100. {% if paragraph_title and paragraph_title_status %}<h2 class="text-center">{% spaceless %}{{- paragraph_title|striptags -}}{% endspaceless %}</h2>{% endif %}
  101. {{ title_suffix }}
  102. {% if add_container %}<div class="container">{% endif %}
  103. <div class="row">
  104. <div class="{{- VBP.bp_width.value -}}">
  105. <ol class="carousel-indicators">
  106. {% for key, item in content.bp_slide_content if key|first != '#' %}
  107. <li class="{% if loop.first %}active{% endif %}" data-slide-to="{{ key }}" data-target="#{{ paragraph_id }}"></li>
  108. {% endfor %}
  109. </ol>
  110. <div class="carousel-inner" role="listbox">
  111. {% for key, item in content.bp_slide_content if key|first != '#' %}
  112. <div class="paragraph--layout-slideshow__slide-{{ key + 1 }} item carousel-item{% if loop.first %} active{% endif %}">{{ item }}</div>
  113. {% endfor %}
  114. </div>
  115. <a class="left carousel-control" href="#{{ paragraph_id }}" role="button" data-slide="prev">
  116. <span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
  117. <span class="sr-only">Previous</span>
  118. </a>
  119. <a class="right carousel-control" href="#{{ paragraph_id }}" role="button" data-slide="next">
  120. <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
  121. <span class="sr-only">Next</span>
  122. </a>
  123. </div>
  124. </div>
  125. {% if add_container %}</div>{% endif %}
  126. </div>