custom/plugins/SchilderSysteme/src/Resources/views/storefront/block/cms-block-popular-categories-slider.html.twig line 1

Open in your IDE?
  1. {% block block_category %}
  2.     <div class="cms-element-categories-slider">
  3.         {% for slot in block.slots %}
  4.             {% if slot.type == "categories-head" %}
  5.                 {% block block_categories_head %}
  6.                     {% set element = block.slots.getSlot(slot.slot) %}
  7.                     {% sw_include "@Storefront/storefront/element/cms-element-categories-head.html.twig" with {
  8.                         isSlider: true,
  9.                     } %}
  10.                 {% endblock %}
  11.             {% endif %}
  12.         {% endfor %}
  13.         <div class="categories-slider">
  14.             {% for slot in block.slots %}
  15.                 {% if slot.type == "category-slider" %}
  16.                     {% block block_categories_slider %}
  17.                         {% set element = block.slots.getSlot(slot.slot) %}
  18.                         {% sw_include "@Storefront/storefront/element/cms-element-category-slider.html.twig" %}
  19.                     {% endblock %}
  20.                 {% endif %}
  21.             {% endfor %}
  22.         </div>
  23.         <pre>{{ dump(block.slots) }}</pre>
  24.         <pre>{{ dump(block.slots|category_check_property) }}</pre>
  25.         <div class="cms-element-categories">
  26.             {% set iconMediaIds = [] %}
  27.             {% set slots = block.slots|category_check_property|sort((a, b) => a.slot|slice(5,length)|number_format <=> b.slot|slice(5,length)|number_format) %}
  28.             {% for slot in slots %}
  29.                 {% if slot.data[0].customFields.custom_category_icon_icon %}
  30.                     {% set iconMediaId = slot.data[0].customFields.custom_category_icon_icon %}
  31.                     {% set iconMediaIds = iconMediaIds|merge([iconMediaId]) %}
  32.                 {% endif %}
  33.             {% endfor %}
  34.             {% set mediaCollection = searchMedia(iconMediaIds, context.context) %}
  35.             {% for slot in slots %}
  36.                 {% if slot.data[0].customFields.custom_category_icon_icon %}
  37.                     {% set icon = slot.data[0].customFields.custom_category_icon_icon %}
  38.                     {% set iconMedia = mediaCollection.get(icon) %}
  39.                 {% endif %}
  40.                 {% block block_category_item %}
  41.                     {% set element = block.slots.getSlot(slot.slot) %}
  42.                     <a class="cms-element-categories-small-item" href="{{ slot.data[0].customFields.custom_category_menu_banner_url }}">
  43.                         {% if iconMedia %}
  44.                         {% sw_thumbnails 'my-thumbnails' with {
  45.                             media: iconMedia,
  46.                             attributes: {
  47.                                 'class': 'category-button-icon',
  48.                                 'title': element.data.all[0].translated.name
  49.                             }
  50.                         } %}
  51.                         {% endif %}
  52.                         {{ element.data.all[0].translated.name }}
  53.                     </a>
  54.                 {% endblock %}
  55.                 {% set icon = null %}
  56.                 {% set iconMedia = null %}
  57.             {% endfor %}
  58.         </div>
  59.     </div>
  60. {% endblock %}