{# # Riccardo: Sortenfarbe und Namensaufteilung für Karten & Produktbühne. # Aufruf: {% sw_include '@RiccardoTheme/storefront/rz/flavor.html.twig' %} setzt nichts – # stattdessen die Makros importieren: {% import '@RiccardoTheme/storefront/rz/flavor.html.twig' as rz %} #} {% macro color(product) %}{% apply spaceless %} {%- set cf = product.translated.customFields|default({}) -%} {%- set tintColors = { frucht: '#FF7A6B', kuehl: '#86D3E8', suess: '#FFD66B', tabak: '#D2B48C', getraenk: '#BBA6FF' } -%} {%- if cf.rz_color is defined and cf.rz_color -%} {{- cf.rz_color -}} {%- elseif cf.rz_tint is defined and tintColors[cf.rz_tint] is defined -%} {{- tintColors[cf.rz_tint] -}} {%- endif -%} {% endapply %}{% endmacro %} {# 0 = Linie/Marke (klein), 1 = Sortenname (groß), 2 = Zusatz (klein) – getrennt durch "|" #} {% macro nameParts(product, flavored) %}{% apply spaceless %} {%- set cfName = product.translated.customFields|default({}) -%} {%- set manu = product.manufacturer ? product.manufacturer.translated.name : (cfName.rz_brand|default('')) -%} {%- set parts = product.translated.name|replace({' – ': ' - ', ' — ': ' - '})|split(' - ')|map(p => p|trim) -%} {%- if manu and parts[0]|lower starts with manu|lower -%} {#- Marke steht schon im Namen: sie wird zur Linie, der Rest ist der Sortenname -#} {%- set head = parts[0]|slice(manu|length)|trim(' -–') -%} {{- manu }}|{{ head ?: parts[0] }}|{{ parts|slice(1)|join(' · ') -}} {%- elseif flavored and parts|length >= 2 -%} {{- parts[0] }}|{{ parts[1] }}|{{ parts|slice(2)|join(' · ') -}} {%- else -%} {{- manu }}|{{ parts[0] }}|{{ parts|slice(1)|join(' · ') -}} {%- endif -%} {% endapply %}{% endmacro %}