{# Display disclaimer if any of the 'trigger' widgets specified in option.affiliatedisclaimer_triggers are in ... # option.affiliatedisclaimer_active - optional array with widget keys # record.custom_integrations - array with widgets keys set by editors in the cms (field name can be changed with option affiliatedisclaimer_customs_field) # record.text - structured-content sections in added in the backend (field name can be changed with option affiliatedisclaimer_structured_field) # # Sample implementation: # {% include 'components/widget/affiliatedisclaimer.twig' with {options: options} %} #} {% set options = options|default({}) + { affiliatedisclaimer_active: [], affiliatedisclaimer_container_class: '', affiliatedisclaimer_col_class: '', affiliatedisclaimer_row_class: 'justify-content-center', affiliatedisclaimer_triggers: ['skimlinks','tracdelight'], affiliatedisclaimer_structured_field: 'text', affiliatedisclaimer_customs_field: 'custom_integrations', affiliatedisclaimer_text: theme.widgets['affiliate-disclaimer'].text|default('Hinweis zu Affiliate-Links: Alle Produkte werden von der Redaktion unabhängig ausgewählt. Im Falle eines Kaufs des Produkts nach Klick auf den Link erhalten wir ggf. eine Provision.'), } %} {# Collect all currently active components from ... #} {# ... manually set in options #} {% set active = options.affiliatedisclaimer_active %} {# ... all section types from structured content field #} {% set active = active|merge(record.get(options.affiliatedisclaimer_structured_field)|scsectiontypes) %} {# ... keys from option custom_integrations field of record #} {% if record|default and record.get(options.affiliatedisclaimer_customs_field)|default and record.get(options.affiliatedisclaimer_customs_field) is iterable %} {% set active = active|merge(record[options.affiliatedisclaimer_customs_field]) %} {% endif %} {# Set hasAffiliate flag if any currently active component is in triggers list #} {% set hasAffiliate = false %} {% for key in options.affiliatedisclaimer_triggers %} {% if key in active %} {% set hasAffiliate = true %} {% endif %} {% endfor %} {% if hasAffiliate %}
{% endif %}