You are here

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

Bootstrap Paragraphs template for displaying a Modal.

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-modal.html.twig
View source
  1. {#
  2. /**
  3. * @file
  4. * Bootstrap Paragraphs template for displaying a Modal.
  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-modal') }}
  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. {# The template default set classes. #}
  48. {%
  49. set classes = [
  50. 'paragraph',
  51. 'paragraph--type--' ~ paragraph.bundle|clean_class,
  52. view_mode ? 'paragraph--view-mode--' ~ view_mode|clean_class,
  53. ]
  54. %}
  55. {# Merges Background color with classes. #}
  56. {% set background_field = content.bp_background|render %}
  57. {% if background_field %}
  58. {% set classes = classes|merge(layout_background_classes) %}
  59. {% endif %}
  60. {# Sets Unique ID for Modal from Paragraph ID. #}
  61. {% set paragraph_id_modal = 'vbp-modal-' ~ paragraph.id.value %}
  62. {% set paragraph_id = 'vbp-' ~ paragraph.id.value %}
  63. {# Sets paragraph title for paragraph. #}
  64. {% set paragraph_title = content.bp_title[0]['#context']['value']|render %}
  65. {# Sets paragraph title status for paragraph. #}
  66. {% set paragraph_title_status = true %}
  67. {% if VBP.bp_title_status.value %}
  68. {% set paragraph_title_status = false %}
  69. {% endif %}
  70. {# No container by default. #}
  71. {% set add_container = false %}
  72. {# If there is BG image it's always edge to edge #}
  73. {% if (VBP.background_image.url or content.bp_background|render) %}
  74. {% set attributes = attributes.addClass('bg-edge2edge') %}
  75. {% set add_container = true %}
  76. {% endif %}
  77. {# If gutter option were selected. #}
  78. {% if VBP.bp_gutter.value %}
  79. {% set add_container = true %}
  80. {% endif %}
  81. {% if VBP.background_image.url %}
  82. {% set attributes = attributes.addClass('background-style') %}
  83. {% endif %}
  84. {# Add custom paragraph CSS class(es). #}
  85. {% if VBP.bp_classes.value %}
  86. {% set striped_custom_classes = VBP.bp_classes.value|striptags|lower %}
  87. {% set split_custom_classes = striped_custom_classes|split(' ') %}
  88. {% for custom_class in split_custom_classes %}
  89. {% set clened_custom_class = [ custom_class|clean_class ] %}
  90. {% set classes = classes|merge(clened_custom_class) %}
  91. {% endfor %}
  92. {% endif %}
  93. {# Prints div with classes, and button to trigger the modal. #}
  94. <div{{ attributes.addClass(classes).setAttribute('id', paragraph_id) }} {% if VBP.background_image.url %} style="background-image:url({{- VBP.background_image.url -}});" {% endif %}>
  95. {% if add_container %}<div class="container">{% endif %}
  96. <div class="row">
  97. <div class="{{- VBP.bp_width.value -}}">
  98. {% if paragraph_title and paragraph_title_status %}<h2 class="text-center">{% spaceless %}{{- paragraph_title|striptags -}}{% endspaceless %}</h2>{% endif %}
  99. {{ title_suffix }}
  100. {# Button trigger modal #}
  101. <button type="button" class="btn btn-primary btn-lg btn-modal" data-toggle="modal" data-target="#{{ paragraph_id_modal }}">
  102. {{ content.bp_modal_button_text }}
  103. </button>
  104. </div>
  105. </div>
  106. {% if add_container %}</div>{% endif %}
  107. </div>
  108. {# Modal markup with modal title, and loops for modal body and modal footer. #}
  109. <div class="modal fade" id="{{ paragraph_id_modal }}" tabindex="-1" role="dialog" aria-labelledby="{{ paragraph_id_modal }}-label" aria-hidden="true">
  110. <div class="modal-dialog" role="document">
  111. <div class="modal-content">
  112. <div class="modal-header">
  113. {% if content.bp_modal_title|render %}
  114. <div class="modal-title" id="{{ paragraph_id_modal }}-label">
  115. {{ content.bp_modal_title }}
  116. </div>
  117. {% endif %}
  118. <button type="button" class="close" data-dismiss="modal" aria-label="Close">
  119. <span aria-hidden="true">&times;</span>
  120. </button>
  121. </div>
  122. {% if content.bp_modal_body|render %}
  123. <div class="modal-body">
  124. {% for key, item in content.bp_modal_body if key|first != '#' %}
  125. {{ item }}
  126. {% endfor %}
  127. </div>
  128. {% endif %}
  129. {% if content.bp_modal_footer|render %}
  130. <div class="modal-footer">
  131. {% for key, item in content.bp_modal_footer if key|first != '#' %}
  132. {{ item }}
  133. {% endfor %}
  134. </div>
  135. {% endif %}
  136. </div>
  137. </div>
  138. </div>