You are here

paragraph--bp-columns-two-uneven.html.twig in Varbase Bootstrap Paragraphs 8.7

Bootstrap Paragraphs template for displaying a Two Columns Uneven layout.

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-columns-two-uneven.html.twig
View source
  1. {#
  2. /**
  3. * @file
  4. * Bootstrap Paragraphs template for displaying a Two Columns Uneven layout.
  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. {# Background color. #}
  42. {% if content.bp_background|render %}
  43. {% set layout_background = content.bp_background['#items'].getString() %}
  44. {% set layout_background_classes = [ layout_background ] %}
  45. {% endif %}
  46. {# Renders Column Style field. #}
  47. {# Sets class name from values in database. #}
  48. {% if content.bp_column_style_2|render %}
  49. {% set column_style_2 = content.bp_column_style_2['#items'].getString() %}
  50. {% set col_1 = [
  51. 'paragraph--style--75-25' == column_style_2 ? 'col-lg-9',
  52. 'paragraph--style--66-33' == column_style_2 ? 'col-lg-8',
  53. 'paragraph--style--25-75' == column_style_2 ? 'col-lg-3',
  54. 'paragraph--style--33-66' == column_style_2 ? 'col-lg-4',
  55. ]
  56. %}
  57. {% set col_2 = [
  58. 'paragraph--style--75-25' == column_style_2 ? 'col-lg-3',
  59. 'paragraph--style--66-33' == column_style_2 ? 'col-lg-4',
  60. 'paragraph--style--25-75' == column_style_2 ? 'col-lg-9',
  61. 'paragraph--style--33-66' == column_style_2 ? 'col-lg-8',
  62. ]
  63. %}
  64. {% endif %}
  65. {# The template default set classes. #}
  66. {%
  67. set classes = [
  68. 'paragraph',
  69. 'paragraph--type--' ~ paragraph.bundle|clean_class,
  70. view_mode ? 'paragraph--view-mode--' ~ view_mode|clean_class,
  71. ]
  72. %}
  73. {# col classes #}
  74. {% set col_attribute = create_attribute() %}
  75. {% set col_classes = [] %}
  76. {# Merges Background color with classes. #}
  77. {% set background_field = content.bp_background|render %}
  78. {% if background_field %}
  79. {% set classes = classes|merge(layout_background_classes) %}
  80. {% endif %}
  81. {# No container by default. #}
  82. {% set add_container = false %}
  83. {# If there is BG image it's always edge to edge #}
  84. {% if (VBP.background_image.url or content.bp_background|render) %}
  85. {% set attributes = attributes.addClass('bg-edge2edge') %}
  86. {% set add_container = true %}
  87. {% endif %}
  88. {# If gutter option were selected. #}
  89. {% if VBP.bp_gutter.value %}
  90. {% set add_container = true %}
  91. {% endif %}
  92. {% if VBP.background_image.url %}
  93. {% set attributes = attributes.addClass('background-style') %}
  94. {% endif %}
  95. {# Sets Unique ID for paragraph from Paragraph ID. #}
  96. {% set paragraph_id = 'vbp-' ~ paragraph.id.value %}
  97. {# Sets paragraph title for paragraph. #}
  98. {% set paragraph_title = content.bp_title[0]['#context']['value']|render %}
  99. {# Sets paragraph title status for paragraph. #}
  100. {% set paragraph_title_status = true %}
  101. {% if VBP.bp_title_status.value %}
  102. {% set paragraph_title_status = false %}
  103. {% endif %}
  104. {# Add custom paragraph CSS class(es). #}
  105. {% if VBP.bp_classes.value %}
  106. {% set striped_custom_classes = VBP.bp_classes.value|striptags|lower %}
  107. {% set split_custom_classes = striped_custom_classes|split(' ') %}
  108. {% for custom_class in split_custom_classes %}
  109. {% set clened_custom_class = [ custom_class|clean_class ] %}
  110. {% set classes = classes|merge(clened_custom_class) %}
  111. {% endfor %}
  112. {% endif %}
  113. {# Prints div with classes, and content without Width and Background. #}
  114. <div{{ attributes.addClass(classes).setAttribute('id', paragraph_id) }} {% if VBP.background_image.url %} style="background-image:url({{- VBP.background_image.url -}});" {% endif %}>
  115. {% if add_container %}<div class="container">{% endif %}
  116. <div class="row">
  117. <div class="{{- VBP.bp_width.value -}}">
  118. {% if paragraph_title and paragraph_title_status %}<h2 class="text-center">{% spaceless %}{{- paragraph_title|striptags -}}{% endspaceless %}</h2>{% endif %}
  119. <div class="row">
  120. {% for key, item in content.bp_column_content_2 if key|first != '#' %}
  121. {% set attributes = attributes.removeClass('bg-edge2edge').removeAttribute('id') %}
  122. {% set column_style_field = content.bp_column_style_2|render %}
  123. {% set col_classes= "" %}
  124. {% if column_style_field %}
  125. {% if loop.index == 1 %}
  126. {% set col_classes = col_1 %}
  127. {% endif %}
  128. {% if loop.index == 2 %}
  129. {% set attributes = attributes.removeClass(col_1) %}
  130. {% set col_classes = col_2 %}
  131. {% endif %}
  132. {% endif %}
  133. <div{{ attributes.removeClass(classes).addClass(col_classes).addClass('p-0') }}>{{ item }}</div>
  134. {% endfor %}
  135. </div>
  136. </div>
  137. </div>
  138. {% if add_container %}</div>{% endif %}
  139. </div>