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.                     {% if item.buttonShow %}
  15.                         <li class="swiper-slide">
  16.                             <div class="b1home_block">
  17.                                 {% set imageDesktop = item.imageDesktop %}
  18.                                 {% set imageTablet = item.imageTablet ?: imageDesktop %}
  19.                                 {% set imageMobile = item.imageMobile ?: imageTablet %}
  20.                                 <figure class="b1home_banner homeChangeImages" data-image="{{ asset(imageDesktop|image_path) }};{{ asset(imageTablet|image_path) }};{{ asset(imageMobile|image_path) }}">
  21.                                     {% if item.text %}
  22.                                         <span class="before_capa_left"></span>
  23.                                     {% endif %}
  24.                                 </figure>
  25.                                 <div class="b1home_info">
  26.                                     <div class="b1home_content ww_center">
  27.                                         {% if item.text %}
  28.                                             <div class="b1home_title">
  29.                                                 {{ item.text|raw }}
  30.                                             </div>
  31.                                         {% endif %}
  32.                                         {% if item.buttonShow and item.buttonLink %}
  33.                                             <div class="b1home_button">
  34.                                                 <a href="{{ item.buttonLink }}" class="btn btn_blue btn_icon" target="{{ item.buttonTarget|url_target }}">
  35.                                                     {{ item.buttonText ?: 'Ver más' }}
  36.                                                     <span class="icon-arrow_forward_ios"></span>
  37.                                                 </a>
  38.                                             </div>
  39.                                         {% endif %}
  40.                                     </div>
  41.                                 </div>
  42.                             </div>
  43.                         </li>
  44.                     {% elseif not item.buttonShow and item.buttonLink %}
  45.                         <li class="swiper-slide">
  46.                             <a href="{{ item.buttonLink }}" class="b1home_block" target="{{ item.buttonTarget|url_target }}">
  47.                                 {% set imageDesktop = item.imageDesktop %}
  48.                                 {% set imageTablet = item.imageTablet ?: imageDesktop %}
  49.                                 {% set imageMobile = item.imageMobile ?: imageTablet %}
  50.                                 <figure class="b1home_banner homeChangeImages" data-image="{{ asset(imageDesktop|image_path) }};{{ asset(imageTablet|image_path) }};{{ asset(imageMobile|image_path) }}">
  51.                                     {#<span class="before_capa_left"></span>#}
  52.                                 </figure>
  53.                             </a>
  54.                         </li>
  55.                     {% endif %}
  56.                 {% endfor %}
  57.             </ul>
  58.             <div class="b1home_pager"></div>
  59.         </div>
  60.     </section>
  61.     {% if sd.detailShow and sd.detailItems|length > 0 %}
  62.         <section class="b2home">
  63.             <div class="b2home_items">
  64.                 {% for item in sd.detailItems %}
  65.                     <a href="{{ item.link }}" class="b2home_box" target="{{ item.target|url_target }}">
  66.                         <figure class="b2home_portada">
  67.                             <img src="{{ asset(item.image|image_path) }}" width="395" height="395" alt="{{ item.title }}">
  68.                         </figure>
  69.                         <div class="b2home_info">
  70.                             {% if item.logo|image_path %}
  71.                                 <figure class="b2home_logo">
  72.                                     <img src="{{ asset(item.logo|image_path) }}" width="220" height="85" alt="{{ item.title }}">
  73.                                 </figure>
  74.                             {% else %}
  75.                                 <h2 class="b2home_title">{{ item.title }}</h2>
  76.                             {% endif %}
  77.                             <span class="b2home_number">{{ loop.index|str_pad(2, 0, constant('STR_PAD_LEFT')) }}</span>
  78.                         </div>
  79.                     </a>
  80.                 {% endfor %}
  81.             </div>
  82.         </section>
  83.     {% endif %}
  84.     {% if sd.sparePartsShow and sd.sparePartsImageDesktop|image_path %}
  85.         <section class="b3home">
  86.             <div class="b3home_content ww_center">
  87.                 {% set imageDesktop = sd.sparePartsImageDesktop %}
  88.                 {% set imageTablet = sd.sparePartsImageTablet ?: imageDesktop %}
  89.                 {% set imageMobile = sd.sparePartsImageMobile ?: imageTablet %}
  90.                 <figure class="b3home_portada homeChangeImages" data-image="{{ asset(imageDesktop|image_path) }};{{ asset(imageTablet|image_path) }};{{ asset(imageMobile|image_path) }}"></figure>
  91.                 <div class="b3home_block">
  92.                     <div class="b3home_info">
  93.                         {% if sd.sparePartsTitle1 %}
  94.                             <h2 class="b3home_title">{{ sd.sparePartsTitle1 }}</h2>
  95.                         {% endif %}
  96.                         {% if sd.sparePartsTitle2 %}
  97.                             <h3 class="b3home_subtitle">{{ sd.sparePartsTitle2 }}</h3>
  98.                         {% endif %}
  99.                         <div class="b3home_button">
  100.                             <a href="{{ path('quotation_request') }}" class="btn btn_blue btn_icon">
  101.                                 {{ sd.sparePartsButtonText ?: 'Solicitar aquí' }}
  102.                                 <span class="icon-arrow_forward_ios"></span>
  103.                             </a>
  104.                         </div>
  105.                     </div>
  106.                 </div>
  107.             </div>
  108.         </section>
  109.     {% endif %}
  110.     {% if info.showBlog and sd.blogShow %}
  111.         <section class="b4home" id="b4_blog_posts" style="display: none;">
  112.             <div class="b4home_content ww_center">
  113.                 <div class="b4home_head">
  114.                     {% if sd.blogTitle %}
  115.                         <h2 class="b4home_title">{{ sd.blogTitle }}</h2>
  116.                     {% endif %}
  117.                     <div class="b4home_button">
  118.                         <a href="{{ info.socialBlogLink }}" class="btn btn_grayline btn_icon" target="_blank">
  119.                             {{ sd.blogButtonText ?: 'Visitar Blog' }}
  120.                             <span class="icon-arrow_forward_ios"></span>
  121.                         </a>
  122.                     </div>
  123.                 </div>
  124.                 <div class="b4home_items" id="b4_content_posts"></div>
  125.             </div>
  126.         </section>
  127.     {% endif %}
  128.     {% if info.rouletteActive and info.rouletteBannerHome|image_path %}
  129.         <a href="{{ path('roulette') }}" class="barfixed" style="background-image:url('{{ asset(info.rouletteBannerHome|image_path) }}');"></a>
  130.     {% endif %}
  131. {% endblock %}
  132. {% block jsfinal %}
  133.     <script src="{{ asset('static/js/swiper/swiper.js') }}"></script>
  134.     <script>
  135.         //- condición cuando se llega a la seccion del footer
  136.         $( window ).scroll(function(e) {
  137.             var altura = $('.footer').height();
  138.             if($(window).scrollTop() + $(window).height() > $(document).height()-altura) {
  139.                 $('.barfixed').addClass('barfixed_hide');
  140.             }else{
  141.                 $('.barfixed').removeClass('barfixed_hide');
  142.             }
  143.         });
  144.         $(function(){
  145.             changeImage('.homeChangeImages');
  146.             window.onresize = function(){
  147.                 changeImage('.homeChangeImages');
  148.             };
  149.             var b1homeSwiper = new Swiper('.b1home_slider.swiper-container', {
  150.                 loop: ($('.b1home_slider.swiper-container .swiper-slide').length > 1),
  151.                 effect: 'fade',
  152.                 fadeEffect: {
  153.                     crossFade: true
  154.                 },
  155.                 speed: 1000,
  156.                 autoplay: {
  157.                     delay: 5000,
  158.                     disableOnInteraction: false
  159.                 },
  160.                 pagination: {
  161.                     el: '.b1home_pager',
  162.                     clickable: true,
  163.                 }
  164.             });
  165.             getBlogPosts();
  166.             function getBlogPosts() {
  167.                 $.ajax({
  168.                     url: '{{ path('get-blog-posts') }}',
  169.                     type: 'get',
  170.                     beforeSend: function () {
  171.                         $('#b4_blogposts').hide();
  172.                     },
  173.                     success: function (data) {
  174.                         if (data['success']) {
  175.                             let posts = data['posts'];
  176.                             if (posts.length > 0) {
  177.                                 let postsTopHtml = renderBlogPosts(posts);
  178.                                 $('#b4_content_posts').html(postsTopHtml);
  179.                                 $('#b4_blog_posts').show();
  180.                             }
  181.                         }
  182.                     }
  183.                 })
  184.             }
  185.             function renderBlogPosts($postsData) {
  186.                 let posts = '';
  187.                 $.each($postsData, function (i, v) {
  188.                     posts += renderBlogPost(i + 1, v);
  189.                 })
  190.                 return posts;
  191.             }
  192.             function renderBlogPost(index, post) {
  193.                 return '' +
  194.                     '<a href="' + post['link'] + '" class="b4home_box">' +
  195.                     '   <figure class="b4home_portada" style="background-image:url(' + post['image'] + ');">' +
  196.                     '   </figure>' +
  197.                     '   <div class="b4home_info">' +
  198.                     '       <span class="b4home_info_title">Noticias</span>' +
  199.                     '       <h3 class="b4home_info_subtitle">' + post['title'] + '</h3>' +
  200.                     '       <div class="b4home_info_description">' +
  201.                     '           <p>' + $(post['excerpt']).text() + '</p>' +
  202.                     '       </div>' +
  203.                     '       <div class="b4home_info_team">' +
  204.                     '           <p>Equipo Eurocamiones</p>' +
  205.                     '       </div>' +
  206.                     '       <span class="b4home_info_date">' + post['createdat'] + '</span>' +
  207.                     '   </div>' +
  208.                     '</a>';
  209.             }
  210.         });
  211.     </script>
  212. {% endblock %}