Skip to content

Instantly share code, notes, and snippets.

@davidhellmann
Created April 3, 2018 06:59
Show Gist options
  • Save davidhellmann/ded30aea639abd1e7894a0f4dda0a8b8 to your computer and use it in GitHub Desktop.
Save davidhellmann/ded30aea639abd1e7894a0f4dda0a8b8 to your computer and use it in GitHub Desktop.
{# @var craft \craft\web\twig\variables\CraftVariable #}
{# @var entry \craft\elements\Entry #}
{#
Description of what this file is for
@package neubau_com.neubau-eyewear.www
@author David Hellmann — Fredmansky [[email protected]]
o-cardsProduct
------------------------------------------------------------
#}
{# -- Set Defaults -- #}
{% set defaults = {
cn: 'o-cardsProduct',
modifiers: [],
customClasses: [],
data: {},
js: null,
items: null,
pageInfo: null,
pagionation: null,
paginationSimple: null
} %}
{# -- Merge Default with Options -- #}
{% set opt = opt is defined ? defaults|merge(opt) : defaults %}
{# -- Modul -- #}
{% if opt.items %}
<div class="{{ opt.cn }}
{% for modifier in opt.modifiers %}
{{- modifier | length ? ' ' ~ opt.cn ~ '--' ~ modifier -}}
{% endfor %}
{% for customClass in opt.customClasses %}
{{ customClass | length ? ' ' ~ customClass }}
{% endfor %} {{- opt.js ? ' ' ~ opt.cn|replace({ 'o-' : 'js-' }) : '' -}}"
{% for key, value in opt.data %}
data-{{ key }}="{{ value }}"
{% endfor %}>
<div class="o-box o-box--large">
<div class="o-row">
{% for item in opt.items %}
{% set variants = item.variants | collect %}
{% set uniqueVariants = variants.uniqueVariants %}
{% set label = item.productLabel %}
{% set filterClasses = [] %}
{% set categories = craft.categories.relatedTo(item.variants) %}
{% for category in categories %}
{% set filterClasses = filterClasses | merge([category.groupId ~ '-' ~ category.slug | lower]) %}
{% endfor %}
<div class="{{ opt.cn ~ '__item' }}{% for class in filterClasses %} {{ class }}{% endfor %}">
{% include '_organisms/sliderProductVariants/_template.html' with {
opt: {
js: true,
variants: uniqueVariants,
label: label,
headline: item.entryCustomH1[0] ?? null ?: item.title,
url: item.url,
dominantColor: true,
dominantColorOverwrite: '#fff',
}
} only %}
</div>
{% endfor %}
</div>
</div>
</div>
{% endif %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment