You are here

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

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. {# No container by default. #}
  64. {% set add_container = false %}
  65. {# If there is BG image it's always edge to edge #}
  66. {% if (VBP.background_image.url or content.bp_background|render) %}
  67. {% set attributes = attributes.addClass('bg-edge2edge') %}
  68. {% set add_container = true %}
  69. {% endif %}
  70. {# If gutter option were selected. #}
  71. {% if VBP.bp_gutter.value %}
  72. {% set add_container = true %}
  73. {% endif %}
  74. {% if VBP.background_image.url %}
  75. {% set attributes = attributes.addClass('background-style') %}
  76. {% endif %}
  77. {# Add custom paragraph CSS class(es). #}
  78. {% if VBP.bp_classes.value %}
  79. {% set striped_custom_classes = VBP.bp_classes.value|striptags|lower %}
  80. {% set split_custom_classes = striped_custom_classes|split(' ') %}
  81. {% for custom_class in split_custom_classes %}
  82. {% set clened_custom_class = [ custom_class|clean_class ] %}
  83. {% set classes = classes|merge(clened_custom_class) %}
  84. {% endfor %}
  85. {% endif %}
  86. {# Prints div with classes, and button to trigger the modal. #}
  87. <div{{ attributes.addClass(classes).setAttribute('id', paragraph_id) }} {% if VBP.background_image.url %} style="background-image:url({{- VBP.background_image.url -}});" {% endif %}>
  88. {% if add_container %}<div class="container">{% endif %}
  89. <div class="row">
  90. <div class="{{- VBP.bp_width.value -}}">
  91. {{ title_suffix }}
  92. {# Button trigger modal #}
  93. <button type="button" class="btn btn-primary btn-lg btn-modal" data-toggle="modal" data-target="#{{ paragraph_id_modal }}">
  94. {{ content.bp_modal_button_text }}
  95. </button>
  96. </div>
  97. </div>
  98. {% if add_container %}</div>{% endif %}
  99. </div>
  100. {# Modal markup with modal title, and loops for modal body and modal footer. #}
  101. <div class="modal fade" id="{{ paragraph_id_modal }}" tabindex="-1" role="dialog" aria-labelledby="{{ paragraph_id_modal }}-label" aria-hidden="true">
  102. <div class="modal-dialog" role="document">
  103. <div class="modal-content">
  104. <div class="modal-header">
  105. <button type="button" class="close" data-dismiss="modal" aria-label="Close">
  106. <span aria-hidden="true">&times;</span>
  107. </button>
  108. {% if content.bp_modal_title|render %}
  109. <div class="modal-title" id="{{ paragraph_id_modal }}-label">
  110. {{ content.bp_modal_title }}
  111. </div>
  112. {% endif %}
  113. </div>
  114. {% if content.bp_modal_body|render %}
  115. <div class="modal-body">
  116. {% for key, item in content.bp_modal_body if key|first != '#' %}
  117. {{ item }}
  118. {% endfor %}
  119. </div>
  120. {% endif %}
  121. {% if content.bp_modal_footer|render %}
  122. <div class="modal-footer">
  123. {% for key, item in content.bp_modal_footer if key|first != '#' %}
  124. {{ item }}
  125. {% endfor %}
  126. </div>
  127. {% endif %}
  128. </div>
  129. </div>
  130. </div>