templates/front/default/home.html.twig line 1

Open in your IDE?
  1. {% extends "front/_common/_base.html.twig" %}
  2. {% block linkcanonical %}
  3.     <link rel="canonical" href="{{ absolute_url(path('home')) }}">
  4. {% endblock %}
  5. {% block cssadicional %}
  6. <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/swiper@8/swiper-bundle.min.css" />
  7. {% endblock %}
  8. {% block classbody %}{% endblock %}
  9. {% block content %}
  10. {% if home.bannerShow and home.bannerItemsActive %}
  11. <section class="b1">
  12.     <div class="swiper b1__swiper">
  13.         <ul class="swiper-wrapper">
  14.             {% for item in home.bannerItemsActive %}
  15.             {% set bannerImgB1 = item.imgBg1|image_path ? asset(item.imgBg1|image_path):  asset(item.img|image_path) %}
  16.             {% set bannerImgB2 = item.imgBg2|image_path ? asset(item.imgBg2|image_path):  asset(item.img|image_path) %}
  17.             {% if item.type == 1 %}
  18.             <li class="swiper-slide b1__item">
  19.                 <!-- solo imagen -->
  20.                 {% if item.btnurl %}
  21.                 <a href="{{ item.btnurl }}" target="{{ item.btnblank ? '_blank':'_self' }}">
  22.                 {% else %}
  23.                 <a href="jascript:void(0)">
  24.                 {% endif %}
  25.                     <picture>
  26.                         <source media="(max-width:480px)" srcset="{{bannerImgB2}}" />
  27.                         <source media="(max-width:768px)" srcset="{{bannerImgB1}}" />
  28.                         <img src="{{ asset(item.img|image_path) }}" alt="{{ item.img|image_path }}"/>
  29.                     </picture>
  30.                 </a>
  31.             </li>
  32.             {% else %}
  33.             <li class="swiper-slide b1__item">
  34.                 <!-- imagen, texto y boton -->
  35.                 <picture>
  36.                     <source media="(max-width:480px)" srcset="{{bannerImgB2}}" />
  37.                     <source media="(max-width:768px)" srcset="{{bannerImgB1}}" />
  38.                     <img src="{{ asset(item.img|image_path) }}" alt="{{ item.img|image_path }}"/>
  39.                 </picture>
  40.                 <div class="wancho">
  41.                     <div class="b1__text">
  42.                         <h1>{{item.title}}</h1>
  43.                         {% if item.btnshow and item.btnurl %}
  44.                         <a href="{{ item.btnurl }}" target="{{ item.btnblank ? '_blank':'_self'}}" class="general_button brown">{{item.btntext}}</a>
  45.                         {% endif %}
  46.                     </div>
  47.                 </div>
  48.             </li>
  49.             {% endif %}
  50.             
  51.             {% endfor %}
  52.             
  53.         </ul>
  54.         <div class="swiper-pagination"></div>
  55.     </div>
  56. </section>
  57. {% endif %}
  58. {% if home.categoriesShow and categoriesHome %}
  59. <section class="b2">
  60.     <article class="b2__ctn wancho">
  61.         <div class="b2__left">
  62.             {% if home.categoriesTitle %}
  63.             <h2>{{ home.categoriesTitle}}</h2>
  64.             {% endif %}
  65.             <ul class="b2__list flex">
  66.                 {% for item in categoriesHome %}
  67.                 <li class="b2__item b2__tab {{ loop.first ? 'active': '' }}" data-id="{{ loop.index }}">
  68.                     <img src="{{ asset(item.logoColor|image_path) }}" alt="{{ item.title }}" />
  69.                     <span>{{ item.title }}</span>
  70.                 </li>
  71.                 {% endfor %}
  72.                 <li class="b2__item">
  73.                     <a href="{{ path('trucks') }}">
  74.                         <span>Ver todos</span>
  75.                     </a>
  76.                 </li>
  77.             </ul>
  78.         </div>
  79.         <div class="nav-buttons">
  80.             <div class="button-prev"></div>
  81.             <div class="button-next"></div>
  82.         </div>
  83.     </article>
  84.     <ul class="b2__swiper__container">
  85.         {% for item in categoriesHome %}
  86.         <li class="swiper b2__swiper {{ loop.first ? 'active': '' }}" data-id="{{ loop.index }}">
  87.             <ul class="swiper-wrapper">
  88.                 {% for i in item.machines %}
  89.                 <li class="swiper-slide">
  90.                     <img src="{{ asset(i.imgList|image_path) }}" width="646" height="410" alt="{{ i.imgList|image_alt }}" />
  91.                     <div>
  92.                         <small>{{item.title}}</small>
  93.                         <h3>{{ i.title }}</h3>
  94.                         <a href="{{ path('truck', {'slug' : i.slug}) }}" class="general_button white">Ver modelo</a>
  95.                     </div>
  96.                 </li>
  97.                 {% endfor %}
  98.             </ul>
  99.         </li>
  100.         {% endfor %}
  101.     </ul>
  102. </section>
  103. {% endif %}
  104. {% if home.servicesShow or home.promoShow or home.serviceShow %}
  105. <section class="b3">
  106.     <article class="b3__ctn wancho">
  107.         {% if home.servicesShow and home.servicesItemsActive %}
  108.         <ul class="b3__servicios">
  109.             {% for item in home.servicesItemsActive %}
  110.             <li class="b3__servicios__item">
  111.                 <a href="{{ item.btnurl }}" target="{{ item.btnBlank}}">
  112.                     <!-- si solo es una imagen -->
  113.                     <img src="{{ asset(item.img|image_path ) }}" alt="{{ item.img|image_alt }}" class="b3__externo" />
  114.                     <!-- si es texto imagen y boton -->
  115.                     {% if item.title %}
  116.                     <h3>{{ item.title|block_title|raw }}</h3>
  117.                     {% endif %}
  118.                     {% if item.btntext and item.btnshow %}
  119.                     <div class="general_button whiteFull">{{ item.btntext }}</div>
  120.                     {% endif %}
  121.                 </a>
  122.             </li>
  123.             {% endfor %}
  124.         </ul>
  125.         {% endif %}
  126.         
  127.         {% if home.promoShow %}
  128.         {% set bannerImgB1 = home.promoImgB1|image_path ? asset(home.promoImgB1|image_path) : asset(home.promoImg|image_path) %}
  129.         {% set bannerImgB2 = home.promoImgB2|image_path ? asset(home.promoImg22|image_path) : asset(home.promoImg|image_path) %}
  130.         <a href="{{ home.promoUrl }}" target="{{ home.promoBlank ? '_blank':'_self' }}" class="b3__banner">
  131.             <picture>
  132.                 <source media="(max-width:480px)" srcset="{{ bannerImgB1 }}" />
  133.                 <source media="(max-width:768px)" srcset="{{ bannerImgB2 }}" />
  134.                 <img src="{{ asset(home.promoImg|image_path) }}" />
  135.             </picture>
  136.         </a>
  137.         {% endif %}
  138.         
  139.         {% if home.serviceShow %}
  140.         <div class="b3__extra">
  141.             <div class="b3__extra__info">
  142.                 {% if home.serviceTitle %}
  143.                 <h3>{{ home.serviceTitle }}</h3>
  144.                 {% endif %}
  145.                 {% if home.serviceText %}
  146.                 <p>{{ home.serviceText }}</p>
  147.                 {% endif %}
  148.                 
  149.                 <a href="{{ path('services') }}" class="general_button white">{{ home.serviceBtnText|default('Ver todos') }}</a>
  150.             </div>
  151.             <ul class="b3__extra__list">
  152.                 {% for item in servicesHome %}
  153.                 <li class="b3__extra__item">
  154.                     {% if item.serviceType == 'link'%}
  155.                         {% set linkservice = item.serviceLink %}
  156.                     {% elseif item.serviceType  == 'wsp' %}
  157.                         {% set linkservice = 'https://api.whatsapp.com/send?phone='~ item.serviceWspNum ~'&text=' ~ item.serviceWspMessage %}
  158.                     {% else %}
  159.                         {% set linkservice = path('service', {'slug' : item.slug }) %}
  160.                     {% endif %}
  161.                     <a href="{{ linkservice }}" target="{{ item.serviceTypeTarget ? '_blank' : '_self' }}">
  162.                         <div class="b3__icon">
  163.                             <img src="{{ asset(item.logoHome|image_path) }}" alt="{{  item.logoHome|image_path}}" class="blue" />
  164.                             <img src="{{ asset(item.logoHomeColor|image_path) }}" alt="{{  item.logoHomeColor|image_path}}" class="brown" />
  165.                         </div>
  166.                         <h4>{{  item.title}}</h4>
  167.                         <span>Ver servicio</span>
  168.                         <div class="b3__img">
  169.                             <img src="{{ asset(item.imgHome|image_path) }}" alt="{{ item.imgHome|image_path }}" />
  170.                         </div>
  171.                     </a>
  172.                 </li>
  173.                 {% endfor %}
  174.             </ul>
  175.         </div>
  176.         {% endif %}
  177.     </article>
  178. </section>
  179. {% endif %}
  180. <section class="b4 experiencias">
  181.     <div class="b4__fondo">
  182.         <img class="blue" src="{{STATIC_URL}}img/rectan.png" alt="Rectangulo" /><img
  183.             src="{{STATIC_URL}}img/truckline.png"
  184.             alt=""
  185.         />
  186.     </div>
  187.     <article class="b4__ctn wancho flex jcsb">
  188.         <div class="b4__left">
  189.             <h5>{{ home.expTexto1Left }} <strong>{{ home.expTexto2Left }}</strong></h5>
  190.             {% if home.expTexto3Left %}
  191.             <h6>{{ home.expTexto3Left }}</h6>
  192.             {% endif %}
  193.             <a href="{{ path('about') }}" class="general_button whiteFull">{{ home.expBtnText|default('Conocenos') }}</a>
  194.         </div>
  195.         <div class="b4__right">
  196.             {% if home.expTitleRight %}
  197.             <h5>{{ home.expTitleRight }}</h5>
  198.             {% endif %}
  199.             <div class="b4__testimonio flex aic jcsb">
  200.                 <div class="b4__testimonio__img">
  201.                     <img id="test_img" src="" alt="testimonio" />
  202.                 </div>
  203.                 <div class="b4__testimonio__info">
  204.                     <h6 id="test_title"></h6>
  205.                     <div>
  206.                         <p id="test_nombre"></p>
  207.                         <p id="test_dni"></p>
  208.                     </div>
  209.                 </div>
  210.             </div>
  211.             <ul class="b4__list flex">
  212.                 {% for item in home.expItemsActive %}
  213.                 <li
  214.                     data-nombre="{{ item.name }}"
  215.                     data-dni="{{ item.numdoc }}"
  216.                     data-texto="{{ item.title }}"
  217.                     class="b4__item"
  218.                 >
  219.                     <img src="{{ asset(item.img|image_path) }}" alt="{{ item.img|image_alt }}" />
  220.                 </li>
  221.                 {% endfor %}
  222.             </ul>
  223.         </div>
  224.     </article>
  225. </section>
  226. {% if home.newsShow and info.blogShow and info.blogUrl %}
  227. <section class="b5 noticias">
  228.     <article class="wancho">
  229.         <div class="flex jcsb">
  230.             {% if home.newsTitle %}
  231.             <h5>{{ home.newsTitle }}</h5>
  232.             {% endif %}
  233.             <div class="nav-buttons">
  234.                 <div class="button-prev"></div>
  235.                 <div class="button-next"></div>
  236.             </div>
  237.         </div>
  238.         <div class="swiper b5__swiper">
  239.             <ul class="swiper-wrapper" id="content-blog">
  240.             </ul>
  241.         </div>
  242.         <a href="{{ info.blogUrl }}" target="_blank" class="general_button white">{{ home.newsBtnText|default('Más noticias aquí') }}</a>
  243.     </article>
  244. </section>
  245. {% endif %}
  246. {% endblock %}
  247. {% block jsfinal %}
  248. <script src="https://cdn.jsdelivr.net/npm/swiper@8/swiper-bundle.min.js"></script>
  249. <script type="text/javascript">
  250.     //B1
  251.     const swiper__banner = new Swiper('.b1__swiper', {
  252.         // Optional parameters
  253.         loop: true,
  254.         simulateTouch: false,
  255.         effect: 'fade',
  256.         autoplay: {
  257.             delay: 5000,
  258.         },
  259.         // If we need pagination
  260.         pagination: {
  261.             el: '.swiper-pagination',
  262.             clickable: true,
  263.             renderBullet: (index, className) => {
  264.                 return `<span class="${className}">0${
  265.                     index + 1
  266.                 }<svg width="40px" height="40px" viewBox="0 0 34 34" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
  267.     <defs>
  268.         <filter x="-46.2%" y="-46.2%" width="192.3%" height="192.3%" filterUnits="objectBoundingBox" id="filter-1">
  269.             <feOffset dx="0" dy="2" in="SourceAlpha" result="shadowOffsetOuter1"></feOffset>
  270.             <feGaussianBlur stdDeviation="2" in="shadowOffsetOuter1" result="shadowBlurOuter1"></feGaussianBlur>
  271.             <feColorMatrix values="0 0 0 0 0   0 0 0 0 0   0 0 0 0 0  0 0 0 0.072435462 0" type="matrix" in="shadowBlurOuter1" result="shadowMatrixOuter1"></feColorMatrix>
  272.             <feMerge>
  273.                 <feMergeNode in="shadowMatrixOuter1"></feMergeNode>
  274.                 <feMergeNode in="SourceGraphic"></feMergeNode>
  275.             </feMerge>
  276.         </filter>
  277.     </defs>
  278.     <g id="Symbols" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
  279.         <g id="progress-/-0%" transform="translate(4.000000, 2.000000)">
  280.             <g id="Group-Copy-2" filter="url(#filter-1)">
  281.               <circle class="progress"  cx="11" cy="13" r="16.6" stroke="#c68767" stroke-width="2" stroke-linecap="round" transform='rotate(-83 13 13)' />
  282.             </g>
  283.         </g>
  284.     </g>
  285. </svg></span>`;
  286.             },
  287.         },
  288.     });
  289.     //B1
  290.     //b2
  291.     const tabCount = document.querySelectorAll('.b2__tab');
  292.     const swiperCount = document.querySelectorAll('.b2__swiper');
  293.     tabCount.forEach(tab => {
  294.         tab.addEventListener('click', () => {
  295.             tabCount.forEach(item => {
  296.                 item.classList.remove('active');
  297.             });
  298.             tab.classList.add('active');
  299.             const getItemId = tab.dataset.id;
  300.             swiperCount.forEach(item => {
  301.                 item.classList.remove('active');
  302.             });
  303.             const getSwiper = document.querySelector(`.b2__swiper[data-id="${getItemId}"]`);
  304.             // setTimeout(() => {
  305.             getSwiper.classList.add('active');
  306.             // }, 100);
  307.         });
  308.     });
  309.     swiperCount.forEach(swiperEl => {
  310.         const camion__swiper = new Swiper(swiperEl, {
  311.             loop: true,
  312.             slidesPerView: 1,
  313.             spaceBetween: 5,
  314.             // centerInsufficientSlides: true,
  315.             simulateTouch: false,
  316.             navigation: {
  317.                 nextEl: `.b2 .button-next`,
  318.                 prevEl: `.b2 .button-prev`,
  319.             },
  320.             on: {
  321.                 init: setTimeout(() => {
  322.                     document.querySelector('.b2__swiper__container').classList.add('initialized');
  323.                 }, 700),
  324.             },
  325.         });
  326.     });
  327.     //b2
  328.     //b4
  329.     const itemsb4 = document.querySelectorAll('.b4__item');
  330.     itemsb4[0].classList.add('active')
  331.     setInfo(itemsb4[0]);
  332.     const listItem = document.getElementsByClassName('b4__list')[0];
  333.     listItem.addEventListener('click', event => {
  334.         if (event.target.className == 'b4__item') {
  335.             itemsb4.forEach(item => {
  336.                 item.classList.remove('active');
  337.             });
  338.             event.target.classList.add('active');
  339.             setInfo(event.target);
  340.         }
  341.     });
  342.     if( $('#content-blog').length ) {
  343.         $.get("{{ path('blog_list') }}", function(html) {
  344.             $('#content-blog').html(html);
  345.             //+++ B7HOME +++
  346.             //<<< END >>>
  347.         })
  348.     }
  349.     function setInfo(item) {
  350.         const getNombre = item.dataset.nombre;
  351.         const getDni = item.dataset.dni;
  352.         const getText = item.dataset.texto;
  353.         const getImg = item.querySelector('img').src;
  354.         document.getElementById('test_nombre').innerText = getNombre;
  355.         document.getElementById('test_dni').innerText = (getDni ? 'DNI: ' + getDni : '');
  356.         document.getElementById('test_title').innerText = getText;
  357.         document.getElementById('test_img').setAttribute('src', getImg);
  358.     }
  359.     //b4
  360.     const swiper_news = new Swiper('.b5__swiper', {
  361.         loop: true,
  362.         spaceBetween: 24,
  363.         slidesPerView: 3,
  364.         navigation: {
  365.             nextEl: '.b5 .button-next',
  366.             prevEl: '.b5 .button-prev',
  367.         },
  368.         breakpoints: {
  369.             0: {
  370.                 slidesPerView: 1,
  371.             },
  372.             580: {
  373.                 slidesPerView: 2,
  374.             },
  375.             581: {
  376.                 slidesPerView: 3,
  377.             },
  378.         },
  379.     });
  380.     WidthChange(1024, () => {
  381.         document.querySelector('.b2').appendChild(document.querySelector('.b2 .nav-buttons'));
  382.         document
  383.             .querySelector('.b3__extra')
  384.             .appendChild(document.querySelector('.b3__extra__info .general_button'));
  385.     });
  386.     WidthChange(580, () => {
  387.         document.querySelector('.b3').appendChild(document.querySelector('.b3__extra'));
  388.     });
  389. </script>
  390. {% endblock %}