product_short_description¶
The product_short_description
macro is used to render a tile of a single product included in the given bundle.
Definition¶
Input parameters¶
description¶
string
parameter represents a description to display.
options¶
object
represents an object of product short description options
Option key | Type | Default | Required | Description |
---|---|---|---|---|
options.hasEditorSettingsAppearance | boolean |
- | no | Determine whether the module content appearance should be determined by only by the settings from the text editor or text editor and store theme style |
options.classNames | string |
- | no | Set of classes that will be added to the product short description |
options.showLink | boolean |
- | no | If set to true a link directing to a full description will be rendered if such description exists |
Example¶
In this example we render a simple product short description. To get the product object we use the getProduct() method from ObjectApi.
{% from "@macros/product_short_description.twig" import product_short_description %}
{% set product = ObjectApi.getProduct(product_id) %}
{{ product_short_description(product.shortDescription, { hasEditorSettingsAppearance, showLink: true }) }}
Example¶
In this example we render a product short description with editor settings appearance and a link to a full description.
{% from "@macros/product_short_description.twig" import product_short_description %}
{% set product = ObjectApi.getProduct(product_id) %}
{{ product_short_description(product.shortDescription, { hasEditorSettingsAppearance: true, showLink: true }) }}
Example¶
In this example we render a product short description with editor settings appearance, a link to a full description and additional classnames that make the short description hidden on mobile and tablet resolutions.
{% from "@macros/product_short_description.twig" import product_short_description %}
{% set product = ObjectApi.getProduct(product_id) %}
{{ product_short_description(product.shortDescription, {
hasEditorSettingsAppearance: true,
classNames: 'hidden-xs-only hidden-sm-only'
showLink: true
}) }}
Macro source code¶
{% macro product_short_description(description, options) %}
<product-short-description
class="
product-short-description__content
{% if options.hasEditorSettingsAppearance %} resetcss {% endif %}
{{ options.classNames }}
"
>
<p slot="short-description">
{{ description|raw }}
</p>
{% if options.showLink %}
<h-scroll-to class="link p_s" to="full-description" slot="full-description-link">{{ translate('Go to full description') }}</h-scroll-to>
{% endif %}
</product-short-description>
{% endmacro %}