lb_grid_cta-1.0.1/templates/block--lb-grid-cta.html.twig

templates/block--lb-grid-cta.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.
 * - block_content: Block content entity instance.
 * - items: Referenced paragraph instances for the Grid CTA items.
 * - columns: Columns count for the layout configuration.
 *
 * @see template_preprocess_block()
 * @see template_preprocess_block__lb_grid_cta()
 */
#}
{%
    set classes = [
    'container',
    'block',
    'block--spacing',
    'block-' ~ configuration.provider|clean_class,
    'block-' ~ plugin_id|clean_class,
    'lb-grid-cta'
]
%}

{% set cta_icons_id = 'cta-icons-' ~ configuration['block_revision_id'] %}
{{ attach_library('lb_grid_cta/lb_grid_cta') }}
<div{{ attributes.addClass(classes).setAttribute('id', plugin_id|clean_class ~ configuration['block_revision_id']) }}>
    {{ title_prefix }}
    {{ title_suffix }}

    {% block content %}
        {% if block_content.field_section_title is not empty %}
            <div class="row section-description text-align-center mb-3 mb-lg-5">
                <div class="col-12">
                    <h2{{ title_attributes.addClass('my-3') }}>{{ block_content.field_section_title.value }}</h2>
                    {% if block_content.field_section_subtitle is not empty %}
                        <p>{{ block_content.field_section_subtitle.value|raw }}</p>
                    {% endif %}
                </div>
            </div>
        {% endif %}
        <div id="{{ cta_icons_id }}" class="my-5">
            {% if items is not empty %}
                <div class="row row-cols-1 row-cols-lg-{{ columns}} g-{{ columns}} justify-content-center">
                    {% for key, item in items %}

                        {% set image = false %}
                        {% set media_image = false %}
                        {% set safe_hash = configuration['block_revision_id'] ~ '--' ~ loop.index %}
                        {% set icon_image = false %}
                        {% set cta_attr = create_attribute() %}
                        {%
                            set cta_classes = [
                            'cta_icon-item',
                            'col',
                            'text-center',
                            'mb-3',
                            'mb-lg-5'
                        ]
                        %}
                        {% if item.field_media and item.field_media.0.entity.field_media_image.entity %}
                            {% set media_image = item.field_media.0.entity.field_media_image.entity.uri.value %}
                            {% set image_alt = item.field_media.0.entity.image.0.alt %}
                        {% endif %}
                        {# Setup our SVG or image style. #}

                        {% if media_image %}
                            {% if '.svg' in media_image %}
                                {% set icon_image = true %}
                                {% set image = file_url(media_image) %}
                            {% else %}
                                {% set image = file_url(media_image|image_style('card_image')) %}
                            {% endif %}
                        {% endif %}
                        <div{{ cta_attr.addClass(cta_classes) }}>
                            <div class="card h-100 border-0 shadow pb-4">
                                {% set external = item.field_cta.0.url.external %}
                                {% if item.field_cta.0.url is not empty %}
                                    <a href="{{ item.field_cta.0.url }}" {% if external %}target="_blank"{% endif %} class="d-block text-reset text-decoration-none">
                                {% endif %}
                                    {# image #}
                                    {% if image %}
                                        {% if icon_image %}
                                            <img src="{{ image }}" alt="{{ image_alt }}" class="w-25 h-100 rounded-circle my-4 mx-auto" role="presentation">
                                        {% else %}
                                            <img src="{{ image }}" alt="{{ image_alt }}" class="w-100 mb-4 mx-auto" role="presentation">
                                        {% endif %}
                                    {% endif %}
                                {% if item.field_cta.0.url is not empty %}
                                    </a>
                                {% endif %}
                                <div class="card-body">
                                    {# title #}
                                    {% if item.field_title %}
                                        <h3 class="card-title">{{ item.field_title.value }}</h3>
                                    {% endif %}
                                    {# body #}
                                    {% if item.field_description %}
                                        {{ item.field_description|view({label: 'hidden'})|raw }}
                                    {% endif %}
                                </div>
                                {% if item.field_cta.uri is not empty %}
                                    <footer>
                                        <a href="{{ item.field_cta.0.url }}" {% if external %}target="_blank"{% endif %} class="btn btn-primary filled">{{ item.field_cta.title }}</a>
                                    </footer>
                                {% endif %}
                            </div>
                        </div>
                    {% endfor %}
                </div>
            {% endif %}

            {% if block_content.field_grid_section_cta_link.uri is not empty %}
                <div class="row section-cta justify-content-center my-5">
                    <a href="{{ block_content.field_grid_section_cta_link.0.url }}" class="btn btn-primary filled">{{ block_content.field_grid_section_cta_link.title }}</a>
                </div>
            {% endif %}
        </div>
    {% endblock %}

</div>

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

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