Advertisement
Guest User

Untitled

a guest
Sep 20th, 2017
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.79 KB | None | 0 0
  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.  
  40. {{ attach_library('varbase_bootstrap_paragraphs/vbp-default') }}
  41. {{ attach_library('varbase_bootstrap_paragraphs/vbp-colors') }}
  42. {{ attach_library('varbase_bootstrap_paragraphs/vbp-carousel') }}
  43.  
  44. {# Background color. #}
  45. {% if content.bp_background|render %}
  46. {% set layout_background = content.bp_background['#items'].getString() %}
  47. {% set layout_background_classes = [ layout_background ] %}
  48. {% endif %}
  49.  
  50. {# Renders Slide Interval field. #}
  51. {# Converts database values to classes supplied by template. #}
  52. {% if content.bp_slide_interval|render %}
  53. {% set slide_interval = content.bp_slide_interval['#items'].getString() %}
  54. {% set slide_interval_classes = [ slide_interval ] %}
  55. {% endif %}
  56.  
  57. {# The template default set classes. #}
  58. {%
  59. set classes = [
  60. 'paragraph',
  61. 'paragraph--type--' ~ paragraph.bundle|clean_class,
  62. view_mode ? 'paragraph--view-mode--' ~ view_mode|clean_class,
  63. 'carousel',
  64. 'slide',
  65. ]
  66. %}
  67.  
  68. {# Merges Background color with classes. #}
  69. {% set background_field = content.bp_background|render %}
  70. {% if background_field %}
  71. {% set classes = classes|merge(layout_background_classes) %}
  72. {% endif %}
  73.  
  74. {# If there is BG image it's always edge to edge #}
  75. {% if (content.bp_background|render) %}
  76. {% set attributes = attributes.addClass('bg-edge2edge') %}
  77. {% endif %}
  78.  
  79. {# Sets Unique ID for Carousel from Paragraph ID. #}
  80. {% set paragraph_id = 'myCarousel-' ~ paragraph.id.value %}
  81.  
  82. {# Prints Carousel template. #}
  83. {{ content|without('bp_slide_content','bp_slide_interval', 'bp_width', 'bp_background') }}
  84. <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 %}>
  85. {{ title_suffix }}
  86. <div class="container">
  87. <div id="main_area">
  88. <!-- Slider -->
  89. <div class="row">
  90. <div class="col-sm-8">
  91. <ol class="carousel-indicators">
  92. {% for key, item in content.bp_slide_content if key|first != '#' %}
  93. <li class="{% if loop.first %}active{% endif %}" data-slide-to="{{ key }}" data-target="#{{ paragraph_id }}"></li>
  94. {% endfor %}
  95. </ol>
  96. <div class="carousel-inner" role="listbox">
  97. {% for key, item in content.bp_slide_content if key|first != '#' %}
  98. <div class="paragraph--layout-slideshow__slide-{{ key + 1 }} item carousel-item{% if loop.first %} active{% endif %}">{{ item }}</div>
  99. {% endfor %}
  100. </div>
  101. <a class="left carousel-control" href="#{{ paragraph_id }}" role="button" data-slide="prev">
  102. <span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
  103. <span class="sr-only">Previous</span>
  104. </a>
  105. <a class="right carousel-control" href="#{{ paragraph_id }}" role="button" data-slide="next">
  106. <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
  107. <span class="sr-only">Next</span>
  108. </a>
  109. </div>
  110. <div class="col-sm-4" id="slider-thumbs">
  111. <!-- Bottom switcher of slider -->
  112. <ul class="hide-bullets hide-caption thumbs remove-padding">
  113. {% for key, item in content.bp_slide_content if key|first != '#' %}
  114. <li class="col-sm-4 {% if loop.first %}active{% endif %}" data-slide-to="{{ key }}" data-target="#{{ paragraph_id }}">
  115. <a class="thumbnail" id="carousel-selector-{{ key + 1 }}">{{ item }}</a>
  116. </li>
  117. {% endfor %}
  118. </ul>
  119. </div>
  120. </div>
  121. </div>
  122. </div>
  123. </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement