varbase_bootstrap_paragraphs-9.0.0-alpha1/templates/paragraph--bp-columns-three-uneven.html.twig

templates/paragraph--bp-columns-three-uneven.html.twig
{#
/**
 * @file
 * Bootstrap Paragraphs template for displaying a Three 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.
 *
 * @see template_preprocess_paragraph()
 *
 * @ingroup themeable
 */
#}

{{ attach_library('varbase_bootstrap_paragraphs/vbp-default') }}
{{ attach_library('varbase_bootstrap_paragraphs/vbp-colors') }}

{# Background color. #}
{% if content.bp_background|render %}
  {% set layout_background = content.bp_background['#items'].getString() %}
  {% set layout_background_classes = [ layout_background ] %}
{% endif %}

{# Renders Column Style field. #}
{# Sets class name from values in database. #}
{% if content.bp_column_style_3|render %}
  {%  set column_style_3 = content.bp_column_style_3['#items'].getString() %}
  {% set col_1 = [
    'paragraph--style--25-50-25' == column_style_3 ? 'col-lg-3',
    'paragraph--style--50-25-25' == column_style_3 ? 'col-lg-6',
    'paragraph--style--25-25-50' == column_style_3 ? 'col-lg-3',
    'paragraph--style--16-66-16' == column_style_3 ? 'col-lg-2 col-6',
    'paragraph--style--66-16-16' == column_style_3 ? 'col-lg-8',
    'paragraph--style--16-16-66' == column_style_3 ? 'col-lg-2 col-6',
  ]
  %}
  {% set col_2 = [
    'paragraph--style--25-50-25' == column_style_3 ? 'col-lg-6',
    'paragraph--style--50-25-25' == column_style_3 ? 'col-lg-3',
    'paragraph--style--25-25-50' == column_style_3 ? 'col-lg-3',
    'paragraph--style--16-66-16' == column_style_3 ? 'col-lg-8',
    'paragraph--style--66-16-16' == column_style_3 ? 'col-lg-2 col-6',
    'paragraph--style--16-16-66' == column_style_3 ? 'col-lg-2 col-6',
  ]
  %}
  {% set col_3 = [
    'paragraph--style--25-50-25' == column_style_3 ? 'col-lg-3',
    'paragraph--style--50-25-25' == column_style_3 ? 'col-lg-3',
    'paragraph--style--25-25-50' == column_style_3 ? 'col-lg-6',
    'paragraph--style--16-66-16' == column_style_3 ? 'col-lg-2 col-6',
    'paragraph--style--66-16-16' == column_style_3 ? 'col-lg-2 col-6',
    'paragraph--style--16-16-66' == column_style_3 ? 'col-lg-8',
  ]
  %}
{% endif %}

{# The template default set classes. #}
{%
  set classes = [
    'paragraph',
    'paragraph--type--' ~ paragraph.bundle|clean_class,
    view_mode ? 'paragraph--view-mode--' ~ view_mode|clean_class,
  ]
%}

{# col classes #}
{% set col_attribute = create_attribute() %}
{% set col_classes = [] %}

{# Merges Background color with classes. #}
{% set background_field = content.bp_background|render %}
{% if background_field %}
  {% set classes = classes|merge(layout_background_classes) %}
{% endif %}

{# No container by default. #}
{% set add_container = false %}

{# If there is BG image it's always edge to edge #}
{% if (VBP.background_image.url or content.bp_background|render) %}
    {% set attributes = attributes.addClass('bg-edge2edge') %}
    {% set add_container = true %}
{% endif %}

{# If gutter option were selected. #}
{% if VBP.bp_gutter.value %}
  {% set add_container = true %}
{% endif %}

{% if VBP.background_image.url %}
  {% set attributes = attributes.addClass('background-style') %}
{% endif %}

{# Sets Unique ID for paragraph from Paragraph ID. #}
{% set paragraph_id = 'vbp-' ~ paragraph.id.value %}

{# Sets paragraph title for paragraph. #}
{% set paragraph_title = content.bp_title[0]['#context']['value']|render %}

{# Sets paragraph title status for paragraph. #}
{% set paragraph_title_status = true %}
{% if VBP.bp_title_status.value %}
  {% set paragraph_title_status = false %}
{% endif %}

{# Add custom paragraph CSS class(es). #}
{% if VBP.bp_classes.value %}
  {% set striped_custom_classes = VBP.bp_classes.value|striptags|lower %}
  {% set split_custom_classes = striped_custom_classes|split(' ') %}
  {% for custom_class in split_custom_classes %}
    {% set clened_custom_class = [ custom_class|clean_class ] %}
    {% set classes = classes|merge(clened_custom_class) %}
  {%  endfor %}
{% endif %}

{# Prints div with classes, and content without Width and Background. #}
<div{{ attributes.addClass(classes).setAttribute('id', paragraph_id) }} {% if VBP.background_image.url %} style="background-image: url({{- VBP.background_image.url -}});" {% endif %}>
  {% if add_container %}<div class="container">{% endif %}
    <div class="row">
      <div class="{{- VBP.bp_width.value -}}">
        {% if paragraph_title and paragraph_title_status %}<h2 class="text-center">{% apply spaceless %}{{- paragraph_title|striptags -}}{% endapply %}</h2>{% endif %}
        <div class="row">
          {% set col_loop_index = 0 %}
          {% for key, item in content.bp_column_content_3 %}
            {% if key|first != '#' %}
              {% set col_loop_index = col_loop_index + 1 %}
              {% set column_style_field = content.bp_column_content_3|render %}
              {% set col_classes = [] %}
              {% if column_style_field %}
                {% if col_loop_index == 1 %}
                  {% set col_classes = col_classes|merge(col_1) %}
                {% elseif col_loop_index == 2 %}
                  {% set col_classes = col_classes|merge(col_2) %}
                {% elseif col_loop_index == 3 %}
                  {% set col_classes = col_classes|merge(col_3) %}
                {% endif %}
              {% endif %}

              {% set col_classes = col_classes|merge(['p-0']) %}
              {% set col_attribute = create_attribute() %}
              <div{{ col_attribute.addClass(col_classes) }}>{{ item }}</div>
            {% endif %}
          {% endfor %}
        </div>
      </div>
    </div>
  {% if add_container %}</div>{% endif %}
</div>

Главная | Обратная связь

drupal hosting | друпал хостинг | it patrol .inc