orange_ecom_starter-2.0.x-dev/templates/taxonomy-terms/taxonomy-term--product-categories.html.twig
templates/taxonomy-terms/taxonomy-term--product-categories.html.twig
{#
/**
* @file
* Theme override to display a Product Category taxonomy term.
*
* Available variables:
* - url: URL of the current term.
* - name: Name of the current term.
* - content: Items for the content of the term (fields and description).
* Use 'content' to print them all, or print a subset such as
* 'content.description'. Use the following code to exclude the
* printing of a given child element:
* @code
* {{ content|without('description') }}
* @endcode
* - attributes: HTML attributes for the wrapper.
* - page: Flag for the full page state.
* - term: The taxonomy term entity, including:
* - id: The ID of the taxonomy term.
* - bundle: Machine name of the current vocabulary.
* - view_mode: View mode, e.g. 'full', 'teaser', etc.
*
* @see template_preprocess_taxonomy_term()
*/
#}
{%
set classes = [
'product-category',
term.field_image.entity.fileuri ? 'product-category--with-image',
'taxonomy-term',
'vocabulary-' ~ term.bundle|clean_class,
]
%}
{% set image_attributes = create_attribute() %}
{# Image. #}
{% if term.field_image.entity.fileuri %}
{% set bg_image = term.field_image.entity.fileuri|image_style('background') %}
{% set bg_image_style = style_value ~ 'background-image: url(' ~ bg_image ~ ');' %}
{% set image_attributes = image_attributes.setAttribute('style', bg_image_style) %}
{% set image_attributes = image_attributes.addClass('component-image-strap__bg-image') %}
{% endif %}
<div{{ attributes.setAttribute('id', 'taxonomy-term-' ~ term.id).addClass(classes) }}>
<div class="product-category__header">
{% if term.field_image.entity.fileuri %}
<div class="component-image-strap">
{% if term.field_image.entity.fileuri %}
<div{{ image_attributes }}>
<div class="component-image-strap__image">
{{ content.field_image }}
</div>
</div>
{% endif %}
<div class="component-image-strap__container container-fluid">
<div class="row">
<div class="component-image-strap__col col-md-6"></div>
<div class="component-image-strap__col col-md-6">
<div class="component-image-strap__content">
<div class="component-image-strap__body">
{{ title_prefix }}
<h2 class="product-category__header__title">{{ name }}</h2>
{{ title_suffix }}
{{ content|without('field_image','field_paragraphs_reference') }}
</div>
</div>
</div>
</div>
</div>
</div>
{% else %}
<div class="product-category__header__body">
{{ title_prefix }}
<h3 class="product-category__header__title">{{ name }}</h3>
{{ title_suffix }}
{{ content|without('field_image','field_paragraphs_reference') }}
</div>
{% endif %}
</div>
{# Components. #}
{% if term.field_paragraphs_reference.0.target_id %}
<div class="product-category__components">
{{ content.field_paragraphs_reference }}
</div>
{% endif %}
{# / Components. #}
</div>
