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="{{ asset('static/js/swiper/swiper.css') }}"/>
  7. {% endblock %}
  8. {% block classbody %}header_transparent{% endblock %}
  9. {% block content %}
  10.     <section class="b1home">
  11.         <div class="b1home_slider swiper-container">
  12.             <ul class="swiper-wrapper">
  13.                 {% for item in sd.banner %}
  14.                     <li class="swiper-slide">
  15.                         <div class="b1home_block">
  16.                             {% set imageDesktop = item.imageDesktop %}
  17.                             {% set imageTablet = item.imageTablet ?: imageDesktop %}
  18.                             {% set imageMobile = item.imageMobile ?: imageTablet %}
  19.                             <figure class="b1home_banner homeChangeImages" data-image="{{ asset(imageDesktop|image_path) }};{{ asset(imageTablet|image_path) }};{{ asset(imageMobile|image_path) }}"></figure>
  20.                             <div class="b1home_info">
  21.                                 <div class="b1home_content ww_center">
  22.                                     {% if item.text %}
  23.                                         <h2 class="b1home_title">{{ item.text|nl2br }}</h2>
  24.                                     {% endif %}
  25.                                     {% if item.buttonShow and item.buttonLink %}
  26.                                         <div class="b1home_button">
  27.                                             <a href="{{ item.buttonLink }}" class="btn btn_lightblue" target="{{ item.buttonTarget|url_target }}">{{ item.buttonText ?: 'Ver más' }}</a>
  28.                                         </div>
  29.                                     {% endif %}
  30.                                 </div>
  31.                             </div>
  32.                         </div>
  33.                     </li>
  34.                 {% endfor %}
  35.             </ul>
  36.             <div class="b1home_pager"></div>
  37.         </div>
  38.     </section>
  39.     {% if sd.trucksShow or sd.busesShow %}
  40.         <section class="b2home">
  41.             <div class="b2home_content ww_center">
  42.                 <div class="b2home_blocks">
  43.                     {% if sd.trucksShow %}
  44.                         <div class="b2home_itemblock">
  45.                             <h2 class="b2home_title">{{ sd.trucksTitle ?: 'Camiones' }}</h2>
  46.                             <div class="b2home_slider swiper-container">
  47.                                 <ul class="swiper-wrapper">
  48.                                     {% for item in trucks %}
  49.                                         <li class="b2home_itembox swiper-slide">
  50.                                             <a href="{{ path('model_detail', {'slug': item.slug}) }}" class="b2home_card">
  51.                                                 <figure class="b2home_portada">
  52.                                                     <img src="{{ asset(item.image|image_path) }}" width="250" height="160" alt="{{ item.title }}">
  53.                                                 </figure>
  54.                                                 <h3 class="b2home_subtitle">{{ item.title }}</h3>
  55.                                                 <div class="b2home_btn">
  56.                                                     <div class="btn btn_grayline" href="{{ path('model_detail', {'slug': item.slug}) }}">Más información</div>
  57.                                                 </div>
  58.                                             </a>
  59.                                         </li>
  60.                                     {% endfor %}
  61.                                 </ul>
  62.                             </div>
  63.                             <div class="b2home_link">
  64.                                 <a class="btn btn_lightblue" href="{{ path('model_trucks') }}" target="{{ sd.trucksButtonTarget|url_target }}">{{ sd.trucksButtonTitle ?: 'MÁS MODELOS' }}</a>
  65.                             </div>
  66.                         </div>
  67.                     {% endif %}
  68.                     {% if sd.busesShow %}
  69.                         <div class="b2home_itemblock">
  70.                             <h2 class="b2home_title">{{ sd.busesTitle ?: 'Buses' }}</h2>
  71.                             <div class="b2home_slider swiper-container">
  72.                                 <ul class="swiper-wrapper">
  73.                                     {% for item in buses %}
  74.                                         <li class="b2home_itembox swiper-slide">
  75.                                             <a href="{{ item.link|external_url }}" class="b2home_card">
  76.                                                 <figure class="b2home_portada">
  77.                                                     <img src="{{ asset(item.image|image_path) }}" width="250" height="160" alt="{{ item.title }}">
  78.                                                 </figure>
  79.                                                 <h3 class="b2home_subtitle">{{ item.title }}</h3>
  80.                                                 <div class="b2home_btn">
  81.                                                     <div class="btn btn_grayline" href="{{ item.link|external_url }}">Más información</div>
  82.                                                 </div>
  83.                                             </a>
  84.                                         </li>
  85.                                     {% endfor %}
  86.                                 </ul>
  87.                             </div>
  88.                             <div class="b2home_link">
  89.                                 <a class="btn btn_lightblue" href="{{ path('model_buses') }}" target="{{ sd.busesButtonTarget|url_target }}">{{ sd.busesButtonTitle ?: 'MÁS MODELOS' }}</a>
  90.                             </div>
  91.                         </div>
  92.                     {% endif %}
  93.                 </div>
  94.             </div>
  95.         </section>
  96.     {% endif %}
  97.     {% if sd.detailShow %}
  98.         <section class="b3home">
  99.             <div class="b3home_content ww_center">
  100.                 <div class="b3home_left">
  101.                     {% if sd.detailText %}
  102.                         <div class="b3home_description">
  103.                             <p>{{ sd.detailText|nl2br }}</p>
  104.                         </div>
  105.                     {% endif %}
  106.                     <div class="b3home_items">
  107.                         {% for item in sd.detailOptions %}
  108.                             <a href="{{ item.link }}" class="b3home_box">
  109.                                 <h3 class="b3home_subtitle">{{ item.title }}</h3>
  110.                                 <span class="b3home_number">{{ loop.index|str_pad(2, '0', constant('STR_PAD_LEFT')) }}</span>
  111.                             </a>
  112.                         {% endfor %}
  113.                     </div>
  114.                 </div>
  115.                 {% if sd.detailImage|image_path %}
  116.                     <figure class="b3home_portada" style="background-image:url('{{ asset(sd.detailImage|image_path) }}');"></figure>
  117.                 {% endif %}
  118.             </div>
  119.         </section>
  120.     {% endif %}
  121.     {% if info.showBlog and sd.blogShow %}
  122.         <section class="b4home" id="b4_blog_posts" style="display: none;">
  123.             <div class="b4home_content ww_center">
  124.                 <div class="b4home_head">
  125.                     {% if sd.blogTitle %}
  126.                         <h2 class="b4home_title">{{ sd.blogTitle }}</h2>
  127.                     {% endif %}
  128.                     <div class="b4home_button">
  129.                         <a href="{{ info.socialBlogLink }}" class="btn btn_grayline btn_icon" target="_blank">
  130.                             {{ sd.blogButtonText ?: 'Visitar Blog' }}
  131.                             <span class="icon-arrow_forward_ios"></span>
  132.                         </a>
  133.                     </div>
  134.                 </div>
  135.                 <div class="b4home_items" id="b4_content_posts"></div>
  136.             </div>
  137.         </section>
  138.     {% endif %}
  139.     {% if info.showRoulette and info.rouletteBannerHome|image_path %}
  140.         <a href="{{ info.rouletteLink|external_url }}" target="{{ info.rouletteTarget|url_target }}" class="barfixed" style="background-image:url('{{ asset(info.rouletteBannerHome|image_path) }}');"></a>
  141.     {% endif %}
  142. {% endblock %}
  143. {% block jsfinal %}
  144.     <script src="{{ asset('static/js/swiper/swiper.js') }}"></script>
  145.     <script>
  146.         //- condición cuando se llega a la seccion del footer
  147.         $(window).scroll(function (e) {
  148.             const altura = $('.footer').height();
  149.             if ($(window).scrollTop() + $(window).height() > $(document).height() - altura) {
  150.                 $('.barfixed').addClass('barfixed_hide');
  151.             } else {
  152.                 $('.barfixed').removeClass('barfixed_hide');
  153.             }
  154.         });
  155.         $(function () {
  156.             changeImage('.homeChangeImages');
  157.             window.onresize = function () {
  158.                 changeImage('.homeChangeImages');
  159.             };
  160.             const b1homeSwiper = new Swiper('.b1home_slider.swiper-container', {
  161.                 loop: ($('.b1home_slider.swiper-container .swiper-slide').length > 1),
  162.                 effect: 'fade',
  163.                 fadeEffect: {
  164.                     crossFade: true
  165.                 },
  166.                 speed: 1000,
  167.                 autoplay: {
  168.                     delay: 5000,
  169.                     disableOnInteraction: false
  170.                 },
  171.                 pagination: {
  172.                     el: '.b1home_pager',
  173.                     clickable: true,
  174.                 }
  175.             });
  176.             const b2homeSwiperContain = $('.b2home_slider.swiper-container');
  177.             b2homeSwiperContain.each(function(){
  178.                 const _this = $(this);
  179.                 const b2homeSwiper = new Swiper(_this, {
  180.                     slidesPerView: 4,
  181.                     loop: ($(_this).find('.swiper-slide').length > 4),
  182.                     speed: 1000,
  183.                     breakpoints: {
  184.                         1024: {
  185.                             slidesPerView: 3,
  186.                             loop: ($(_this).find('.swiper-slide').length > 3),
  187.                         },
  188.                         767: {
  189.                             slidesPerView: 'auto',
  190.                             loop: false
  191.                         }
  192.                     }
  193.                     /*
  194.                     autoplay: {
  195.                         delay: 1500,
  196.                         disableOnInteraction: false
  197.                     },
  198.                     navigation: {
  199.                         prevEl: '.b2home_prev',
  200.                         nextEl: '.b2home_next',
  201.                     },
  202.                     */
  203.                 });
  204.             });
  205.             getBlogPosts();
  206.             function getBlogPosts() {
  207.                 $.ajax({
  208.                     url: '{{ path('get-blog-posts') }}',
  209.                     type: 'get',
  210.                     beforeSend: function () {
  211.                         $('#b4_blogposts').hide();
  212.                     },
  213.                     success: function (data) {
  214.                         if (data['success']) {
  215.                             let posts = data['posts'];
  216.                             if (posts.length > 0) {
  217.                                 let postsTopHtml = renderBlogPosts(posts);
  218.                                 $('#b4_content_posts').html(postsTopHtml);
  219.                                 $('#b4_blog_posts').show();
  220.                             }
  221.                         }
  222.                     }
  223.                 })
  224.             }
  225.             function renderBlogPosts($postsData) {
  226.                 let posts = '';
  227.                 $.each($postsData, function (i, v) {
  228.                     posts += renderBlogPost(i + 1, v);
  229.                 })
  230.                 return posts;
  231.             }
  232.             function renderBlogPost(index, post) {
  233.                 return '' +
  234.                     '<a href="' + post['link'] + '" target="_blank" class="b4home_box">' +
  235.                     '   <figure class="b4home_portada" style="background-image:url(' + post['image'] + ');">' +
  236.                     '   </figure>' +
  237.                     '   <div class="b4home_info">' +
  238.                     '       <span class="b4home_info_title">Noticias</span>' +
  239.                     '       <h3 class="b4home_info_subtitle">' + post['title'] + '</h3>' +
  240.                     '       <div class="b4home_info_description">' +
  241.                     '           <p>' + $(post['excerpt']).text() + '</p>' +
  242.                     '       </div>' +
  243.                     '       <div class="b4home_info_team">' +
  244.                     '           <p>Equipo Eurocamiones</p>' +
  245.                     '       </div>' +
  246.                     '       <span class="b4home_info_date">' + post['createdat'] + '</span>' +
  247.                     '   </div>' +
  248.                     '</a>';
  249.             }
  250.         });
  251.     </script>
  252. {% endblock %}