src/Elements/Bundle/DemiFrontendBundle/Resources/views/Brochure/includes/brochure-teaser.html.twig line 1

Open in your IDE?
  1. {# @var brochure \Elements\Demi\Model\ShopItem #}
  2. {% set variants = brochure.getVariants() %}
  3. {% set currentVariant = null %}
  4. {% set isHorizontal = pimcore_checkbox('isHorizontal').getValue() %}
  5. {% set firstImageUrl = demi_demiUrl({
  6.     'path': 'demi',
  7.     'objectId': brochure.getId(),
  8.     'thumbnail': isHorizontal ? 'demi-prospekt-teaser-horizontal' : 'demi-prospekt-teaser',
  9.     'dateFrom':  carbon().create().getTimestamp()
  10. }, 'demi_image', true) %}
  11. {% set links = brochure.getLinks() ? brochure.getLinks().getItems() : [] %}
  12. {% if links|length > 0 %}
  13.     {% set links = demi_sortLinks(links) %}
  14. {% endif %}
  15. <script type="application/javascript" data-cookieconsent="ignore">
  16.     _config.brochuresBookable = _config.brochuresBookable || [];
  17.     _config.brochuresBookable[{{ brochure.getId() }}] = {
  18.         {% for variant in variants %}
  19.                 '{{ variant.getVariationLanguage() }}':  {{ (not variant.getIsNotBookable() and variant.getStock() > 0) ? 'true' : 'false' }} ,
  20.         {% endfor %}
  21.     };
  22. </script>
  23. {% if not selectedLanguage|default(false)%}
  24.     {% set selectedLanguage = app.request.locale %}
  25. {% endif %}
  26. <li class="{{ isHorizontal ? 'col-12' : 'col-xl-3 col-sm-4 col-6 border-right' }} mb-4 js-prospekt-selection__item prospekt-teaser"
  27.     data-prospekt-id="{{ brochure.getId() }}">
  28.     <section class="{{ isHorizontal ? 'row row--gutter-width-20': 'd-flex flex-column justify-content-between h-100' }}">
  29.         {%  if isHorizontal and pimcore_device().isPhone() %}
  30.             <div class="col-12">
  31.                 <h6 class="text-primary fz18">{{ brochure.getName(currentLanguage) }} {{ elements_debug_mode() ? "(oid "~ brochure.getId() ~ ")" : ""  }}</h6>
  32.             </div>
  33.         {% endif %}
  34.         <div class="{{ isHorizontal ? 'col-5 col-sm-3': ''}}">
  35.             <div class="{{ isHorizontal ? 'bg-light-gray p-1': '' }}">
  36.                 <figure class="embed-responsive embed-responsive-{{ isHorizontal ? '3by2': '16by9'}}">
  37.                     <div class="embed-responsive-item center-container">
  38.                         <span class="center-container__item-wrapper">
  39.                             <img data-src="{{ firstImageUrl }}"
  40.                                  class="center-container__item js-lazy-img js-lazy-img--img lazy-img"
  41.                                  alt="{{ brochure.getName(currentLanguage) }}"/>
  42.                             {% do jsConfig().add('lightbox', true) %}
  43.                             
  44.                             {% set gallerySrcUrl = demi_demiUrl({
  45.                                 'path': 'demi',
  46.                                 'objectId': brochure.getId(),
  47.                                 'thumbnail': 'demi-prospekt-gallery',
  48.                                 'thumbSmall': 'demi-prospekt-gallery-small',
  49.                                 'dateFrom':  ''
  50.                             }, 'demi_images') %}
  51.                             <button type="button"
  52.                                     class="btn-show-gallery btn-show-gallery--small btn-no-styling js-lightbox-group-dyn js-tracking--click-piwik"
  53.                                     aria-label="{{ 'demi.detail.open-gallery'|trans }}"
  54.                                     title="{{ 'demi.detail.open-gallery'|trans }}"
  55.                                     data-lightbox-id="lightbox-{{ brochure.getId() }}"
  56.                                     data-lightbox-src-url="{{ gallerySrcUrl }}"
  57.                                     data-tracking-category="Brochure list"
  58.                                     data-tracking-action="open gallery">
  59.                                 <span class="js-lightbox-group-dyn__icon demi-icon demi-icon-search btn-show-gallery__icon"
  60.                                       aria-hidden="true"></span> <span class="js-lightbox-group-dyn__loading"
  61.                                                                        hidden> <span class="text-center d-block">
  62.                                         <span class="circle-spinner circle-spinner--white"
  63.                                               aria-label="{{ 'demi.content-loading'|trans }}"
  64.                                               title="{{ 'demi.content-loading'|trans }}"></span>
  65.                                     </span>
  66.                                 </span>
  67.                             </button>
  68.                         </span>
  69.                     </div>
  70.                 </figure>
  71.                 {% if not isHorizontal %}
  72.                     <h6 class="text-primary text-center my-2 fz15">{{ brochure.getName(currentLanguage) }} {{ elements_debug_mode() ? "(oid "~ brochure.getId() ~ ")" : ""  }}</h6>
  73.                 {% endif %}
  74.             </div>
  75.         </div>
  76.         {% if isHorizontal %}
  77.             <div class="col-7 col-sm-6">
  78.                 {% if pimcore_device().isPhone() %}
  79.                     {% do jsConfig().add('expandable', true) %}
  80.              
  81.                     <div class="js-expandable expandable-block">
  82.                         <div class="expandable-block__content-wrapper js-expandable__content-wrapper expandable-block__content-wrapper--small">
  83.                             <div class="js-expandable__content expandable-block__content">
  84.                                 <div class="wysiwyg">
  85.                                     {% set descriptions = brochure.getDescriptions(carbon().create()) %}
  86.                                     {% if descriptions is iterable %}
  87.                                         {% for description in descriptions %}
  88.                                             {% if description.getDescriptionLanguage() == currentLanguage %}
  89.                                                 {{ description.getText()|raw }}
  90.                                             {% endif %}
  91.                                         {% endfor %}
  92.                                     {% endif %}
  93.                                 </div>
  94.                                 <ul class="list-unstyled">
  95.                                     {% for link in links  %}
  96.                                         {% set tmpUrl = demi_findNiceUrl(link.getUrl()|escape) %}
  97.                                         {% set name = link.getNameLocalized(currentLanguage) ? link.getNameLocalized(currentLanguage) : link.getName() %}
  98.                                         {% if tmpUrl is not empty %}
  99.                                             <li><a class="text-underline text-primary" target="_blank" href="{{ tmpUrl }}">{{ name|escape }}</a></li>
  100.                                         {% endif %}
  101.                                     {% endfor %}
  102.                                 </ul>
  103.                             </div>
  104.                         </div>
  105.                         <div class="expandable-block__more js-expandable__more text-right">
  106.                             <button type="button" class="btn-no-styling text-primary font-medium fz15">
  107.                                 {{ 'demi.detail.read-more'|trans }}
  108.                                 <span class="demi-icon demi-icon-chevron-down icon-in-text ml-2" aria-hidden="true"></span>
  109.                             </button>
  110.                         </div>
  111.                     </div>
  112.                 {% else %}
  113.                     <h6 class="text-primary fz18">{{ brochure.getName(currentLanguage) }}  {{ elements_debug_mode() ? "(oid "~ brochure.getId() ~ ")" : ""  }}</h6>
  114.                     <div class="wysiwyg">
  115.                         {% set descriptions = brochure.getDescriptions(carbon().create()) %}
  116.                         {% if descriptions is iterable %}
  117.                             {% for description in descriptions %}
  118.                                 {% if description.getDescriptionLanguage() == currentLanguage %}
  119.                                     {{ description.getText()|raw }}
  120.                                 {% endif %}
  121.                             {% endfor %}
  122.                         {% endif %}
  123.                     </div>
  124.                     <ul class="list-unstyled">
  125.                         {% for link in links  %}
  126.                             {% set tmpUrl = demi_findNiceUrl(link.getUrl()|escape) %}
  127.                             {% set name = link.getNameLocalized(currentLanguage) ? link.getNameLocalized(currentLanguage) : link.getName() %}
  128.                             {% if tmpUrl is not empty %}
  129.                                 <li><a class="text-underline text-primary" target="_blank" href="{{ tmpUrl }}">{{ name|escape }}</a></li>
  130.                             {% endif %}
  131.                         {% endfor %}
  132.                     </ul>
  133.                 {% endif %}
  134.             </div>
  135.         {% endif %}
  136.         <div class="mt-2 mt-sm-0 {{ isHorizontal ? 'col-12 col-sm-3': '' }} ">
  137.             <label class="form-box form-box--gray mb-2">
  138.                 <span class="form-box__label sr-only">{{ 'demi.brochures.language'|trans }}</span>
  139.                 <select name="language" class="form-box__content form-control js-prospekt-selection__lang" {{ variants|length <= 1 ? 'disabled' : '' }}>
  140.                     {# @var variant \Elements\Demi\Model\ShopItem #}
  141.                     {% for variant in variants %}
  142.                         {% set downloadDocument = variant.getDownloadDocument() %}
  143.                         {% set downloadUrl = downloadDocument ? demi_demiUrl({
  144.                             'id': downloadDocument.getId(),
  145.                             'filenameOverride': (brochure.getName(variant.getVariationLanguage()) ~ "_" ~ variant.getVariationLanguage() ~ ".pdf")|url_encode
  146.                         }, 'demi_download', true) : '' %}
  147.                         {% set language = demi_getClassByStringAndIdentifier("\\Elements\\Demi\\Model\\Language", "getByFid", variant.getVariationLanguage(), 1) %}
  148.                         {% set currentVariant = language.getFid() == selectedLanguage ? variant : currentVariant %}
  149.                         {% if language is not null %}
  150.                             <option value="{{ language.getFid() }}"
  151.                                     data-href="{{ downloadUrl }}"
  152.                                     data-offerId="{{ variant.getId() }}"
  153.                                 {{ language.getFid() == selectedLanguage ? 'selected' : ''}}>
  154.                                 {{ language.getName(currentLanguage) }}
  155.                             </option>
  156.                         {% endif %}
  157.                     {% endfor %}
  158.                     {% set currentVariant = (currentVariant is empty and variants|length > 0) ? variants[0] : currentVariant %}
  159.                 </select>
  160.                 {% if variants|length > 1 %}
  161.                     <span class="demi-icon demi-icon-chevron-down form-box__select-icon" aria-hidden="true"></span>
  162.                 {% endif %}
  163.             </label>
  164.             {% if currentVariant is not null %}
  165.                 {% do jsConfig().add('tracking', true) %}
  166.                 {% set downloadDocument = currentVariant.getDownloadDocument() %}
  167.                 {% set downloadUrl = downloadDocument ? demi_demiUrl({
  168.                             'id': downloadDocument.getId(),
  169.                             'filenameOverride': (brochure.getName(currentVariant.getVariationLanguage()) ~ "_" ~ currentVariant.getVariationLanguage() ~ ".pdf")|url_encode
  170.                  }, 'demi_download', true) : '' %}
  171.                 <a href="{{ downloadUrl }}"
  172.                    class="btn btn-default btn-block text-left mb-2 js-prospekt-selection__item-download js-tracking js-tracking--click"
  173.                    target="_blank"
  174.                    data-tracking-category="Klick Prospekte"
  175.                    data-tracking-action="Download "
  176.                    data-tracking-label="{{ brochure.getName(currentLanguage) }}">
  177.                     <span class="btn__icon demi-icon demi-icon-star mr-1" aria-hidden="true"></span>
  178.                     {{ 'demi.brochures.download'|trans }}
  179.                 </a>
  180.             {% endif %}
  181.             {% set viewUrl = null %}
  182.             {% set viewName = null %}
  183.             {% set links = currentVariant.getLinks() %}
  184.             {% if links is empty %}
  185.                 {% set links = brochure.getLinks() %}
  186.             {% endif %}
  187.             {% if links is not empty %}
  188.                 {% set items = links.getItems() %}
  189.                 {% if items is iterable %}
  190.                     {% for item in items %}
  191.                         {% if item.getLinkType == 1 %}
  192.                         {% set viewUrl = item.getUrl() %}
  193.                         {% set viewName = item.getName() %}
  194.                         {% endif %}
  195.                     {% endfor %}
  196.                 {% endif %}
  197.             {% endif %}
  198.             {% if viewUrl is not null %}
  199.                 <a href="{{ viewUrl }}"
  200.                    class="btn btn-default btn-block text-left mb-2  js-tracking js-tracking--click"
  201.                    target="_blank"
  202.                    data-tracking-category="Klick Prospekte"
  203.                    data-tracking-action="View"
  204.                    data-tracking-label="{{ viewName|escape }}">
  205.                     <span class="btn__icon demi-icon demi-icon-visibility mr-1" aria-hidden="true"></span>
  206.                     {{ 'demi.brochures.view'|trans }}
  207.                 </a>
  208.             {% endif %}
  209.             {% if currentVariant is not null and not currentVariant.getIsNotBookable() and not demi_core_configuration('getIsWhiteLabel', [])%}
  210.                 {{ include('@ElementsDemiFrontend/Includes/elements/buttons/toggle-button.html.twig', {
  211.                     'type': 'checkbox',
  212.                     'name': 'prospekte[]',
  213.                     'isBlock': true,
  214.                     'value': brochure.getId(),
  215.                     'icon': 'check-circle',
  216.                     'text': 'demi.brochures.select'|trans,
  217.                     'isHighlighted': true,
  218.                     'hasIcon': true,
  219.                     'styleModifier': 'js-prospekt-selection__checkbox',
  220.                     'classes': ['toggle-btn--highlighted'],
  221.                     'dataAttr': 'data-offerId=' ~ (currentVariant is not null ? currentVariant.getId() : null)
  222.                 }) }}
  223.             {% endif %}
  224.         </div>
  225.     </section>
  226.     {% if isHorizontal %}
  227.         <hr class="{{ pimcore_device().isPhone() ? 'container-break' : 'mx--4' }}">
  228.     {% endif %}
  229. </li>