ixm_blocks-1.0.x-dev/modules/ixm_blocks_cta_icons/templates/block--ixm-blocks-cta-icons.html.twig

modules/ixm_blocks_cta_icons/templates/block--ixm-blocks-cta-icons.html.twig
{#
/**
 * @file
 * Theme override to display a block.
 *
 * Available variables:
 * - plugin_id: The ID of the block implementation.
 * - label: The configured label of the block if visible.
 * - configuration: A list of the block's configuration values.
 *   - label: The configured label for the block.
 *   - label_display: The display settings for the label.
 *   - provider: The module or other provider that provided this block plugin.
 *   - Block plugin specific settings will also be stored here.
 * - content: The content of this block.
 * - attributes: array of HTML attributes populated by modules, intended to
 *   be added to the main container tag of this template.
 *   - id: A valid HTML ID and guaranteed unique.
 * - title_attributes: Same as attributes, except applied to the main title
 *   tag that appears in the template.
 * - title_prefix: Additional output populated by modules, intended to be
 *   displayed in front of the main title tag that appears in the template.
 * - title_suffix: Additional output populated by modules, intended to be
 *   displayed after the main title tag that appears in the template.
 *
 * @see template_preprocess_block()
 */
#}
{%
  set classes = [
  'block',
  'block-' ~ configuration.provider|clean_class,
  'block-' ~ plugin_id|clean_class,
]
%}

{% set cta_icons_id = 'cta-icons-' ~ configuration['block_revision_id'] %}

<div{{ attributes.addClass(classes).setAttribute('id', plugin_id|clean_class ~ configuration['block_revision_id']) }}>

  {{ title_prefix }}
  {% if label %}
    <h3{{ title_attributes.addClass('mb-5') }}>{{ label }}</h3>
  {% endif %}
  {{ title_suffix }}

  {% block content %}
  <div id="{{ cta_icons_id }}">

    {# ping pong items #}
    {% if content.field_entity_reference_paragraph %}
      <div class="row row-cols-1 row-cols-md-2 row-cols-lg-4 g-4 justify-content-center">

        {% for key, item in content.field_entity_reference_paragraph|filter((value, key) => key|first != '#') %}
        {% set safe_hash = configuration['block_revision_id'] ~ '--' ~ loop.index %}

        {% set cta_attr = create_attribute() %}
        {%
          set cta_classes = [
            'cta_icon-item',
            'col',
            'text-center',
          ]
        %}

        {# Setup our SVG or image style. #}
        {% if item['#paragraph'].field_media_element.0.entity.image.entity.uri.value %}
          {# lightning_media_image 8.x-3x source_field: [image] #}
          {% set media_image = item['#paragraph'].field_media_element.0.entity.image.entity.uri.value %}
          {% set image_alt = item['#paragraph'].field_media_element.0.entity.image.0.alt %}
        {% elseif item['#paragraph'].field_media_element.0.entity.field_media_image.entity.uri.value %}
          {# lightning_media_image 8.x-4x source_field: [field_media_image] #}
          {% set media_image = item['#paragraph'].field_media_element.0.entity.field_media_image.entity.uri.value %}
          {% set image_alt = item['#paragraph'].field_media_element.0.entity.field_media_image.0.alt %}
        {% endif %}

        {% if media_image %}
          {% if '.svg' in media_image|render|render %}
            {% set image = file_url(media_image) %}
          {% else %}
            {% set image = file_url(media_image|image_style('large')) %}
          {% endif %}
        {% endif %}

        <div{{ cta_attr.addClass(cta_classes) }}>
          <div class="card h-100 border-0 shadow p-4">

            {% set external = item['#paragraph'].field_link.0.url.external %}

            {% if item['#paragraph'].field_link.0.url %}
            <a href="{{ item['#paragraph'].field_link.0.url }}" {% if external %}target="_blank"{% endif %} class="text-reset text-decoration-none">
            {% endif %}

              {# image #}
              {% if image %}
                <img src="{{ image }}" alt="{{ image_alt }}" class="w-25 my-4 mx-auto" role="presentation">
              {% endif %}

              <div class="card-body">

                {# title #}
                {% if item['#paragraph'].field_title %}
                  <h3 class="card-title">{{ item['#paragraph'].field_title.value }}</h3>
                {% endif %}

                {# body #}
                {% if item['#paragraph'].field_body %}
                  {{ item['#paragraph'].field_body.value|raw }}
                {% endif %}

              </div>

            {% if item['#paragraph'].field_link.0.url %}
            </a>
            {% endif %}

          </div>
        </div>
      {% endfor %}

      </div>
    {% endif %}
  </div>
  {% endblock %}

</div>

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

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