{% extends "front/_common/_base.html.twig" %}
{% block linkcanonical %}
<link rel="canonical" href="{{ absolute_url(path('home')) }}">
{% endblock %}
{% block cssadicional %}
<link rel="stylesheet" href="{{ asset('static/js/swiper/swiper.css') }}"/>
{% endblock %}
{% block classbody %}header_transparent{% endblock %}
{% block content %}
<section class="b1home">
<div class="b1home_slider swiper-container">
<ul class="swiper-wrapper">
{% for item in sd.banner %}
{% if item.buttonShow %}
<li class="swiper-slide">
<div class="b1home_block">
{% set imageDesktop = item.imageDesktop %}
{% set imageTablet = item.imageTablet ?: imageDesktop %}
{% set imageMobile = item.imageMobile ?: imageTablet %}
<figure class="b1home_banner homeChangeImages" data-image="{{ asset(imageDesktop|image_path) }};{{ asset(imageTablet|image_path) }};{{ asset(imageMobile|image_path) }}">
{% if item.text %}
<span class="before_capa_left"></span>
{% endif %}
</figure>
<div class="b1home_info">
<div class="b1home_content ww_center">
{% if item.text %}
<div class="b1home_title">
{{ item.text|raw }}
</div>
{% endif %}
{% if item.buttonShow and item.buttonLink %}
<div class="b1home_button">
<a href="{{ item.buttonLink }}" class="btn btn_blue btn_icon" target="{{ item.buttonTarget|url_target }}">
{{ item.buttonText ?: 'Ver más' }}
<span class="icon-arrow_forward_ios"></span>
</a>
</div>
{% endif %}
</div>
</div>
</div>
</li>
{% elseif not item.buttonShow and item.buttonLink %}
<li class="swiper-slide">
<a href="{{ item.buttonLink }}" class="b1home_block" target="{{ item.buttonTarget|url_target }}">
{% set imageDesktop = item.imageDesktop %}
{% set imageTablet = item.imageTablet ?: imageDesktop %}
{% set imageMobile = item.imageMobile ?: imageTablet %}
<figure class="b1home_banner homeChangeImages" data-image="{{ asset(imageDesktop|image_path) }};{{ asset(imageTablet|image_path) }};{{ asset(imageMobile|image_path) }}">
{#<span class="before_capa_left"></span>#}
</figure>
</a>
</li>
{% endif %}
{% endfor %}
</ul>
<div class="b1home_pager"></div>
</div>
</section>
{% if sd.detailShow and sd.detailItems|length > 0 %}
<section class="b2home">
<div class="b2home_items">
{% for item in sd.detailItems %}
<a href="{{ item.link }}" class="b2home_box" target="{{ item.target|url_target }}">
<figure class="b2home_portada">
<img src="{{ asset(item.image|image_path) }}" width="395" height="395" alt="{{ item.title }}">
</figure>
<div class="b2home_info">
{% if item.logo|image_path %}
<figure class="b2home_logo">
<img src="{{ asset(item.logo|image_path) }}" width="220" height="85" alt="{{ item.title }}">
</figure>
{% else %}
<h2 class="b2home_title">{{ item.title }}</h2>
{% endif %}
<span class="b2home_number">{{ loop.index|str_pad(2, 0, constant('STR_PAD_LEFT')) }}</span>
</div>
</a>
{% endfor %}
</div>
</section>
{% endif %}
{% if sd.sparePartsShow and sd.sparePartsImageDesktop|image_path %}
<section class="b3home">
<div class="b3home_content ww_center">
{% set imageDesktop = sd.sparePartsImageDesktop %}
{% set imageTablet = sd.sparePartsImageTablet ?: imageDesktop %}
{% set imageMobile = sd.sparePartsImageMobile ?: imageTablet %}
<figure class="b3home_portada homeChangeImages" data-image="{{ asset(imageDesktop|image_path) }};{{ asset(imageTablet|image_path) }};{{ asset(imageMobile|image_path) }}"></figure>
<div class="b3home_block">
<div class="b3home_info">
{% if sd.sparePartsTitle1 %}
<h2 class="b3home_title">{{ sd.sparePartsTitle1 }}</h2>
{% endif %}
{% if sd.sparePartsTitle2 %}
<h3 class="b3home_subtitle">{{ sd.sparePartsTitle2 }}</h3>
{% endif %}
<div class="b3home_button">
<a href="{{ path('quotation_request') }}" class="btn btn_blue btn_icon">
{{ sd.sparePartsButtonText ?: 'Solicitar aquí' }}
<span class="icon-arrow_forward_ios"></span>
</a>
</div>
</div>
</div>
</div>
</section>
{% endif %}
{% if info.showBlog and sd.blogShow %}
<section class="b4home" id="b4_blog_posts" style="display: none;">
<div class="b4home_content ww_center">
<div class="b4home_head">
{% if sd.blogTitle %}
<h2 class="b4home_title">{{ sd.blogTitle }}</h2>
{% endif %}
<div class="b4home_button">
<a href="{{ info.socialBlogLink }}" class="btn btn_grayline btn_icon" target="_blank">
{{ sd.blogButtonText ?: 'Visitar Blog' }}
<span class="icon-arrow_forward_ios"></span>
</a>
</div>
</div>
<div class="b4home_items" id="b4_content_posts"></div>
</div>
</section>
{% endif %}
{% if info.rouletteActive and info.rouletteBannerHome|image_path %}
<a href="{{ path('roulette') }}" class="barfixed" style="background-image:url('{{ asset(info.rouletteBannerHome|image_path) }}');"></a>
{% endif %}
{% endblock %}
{% block jsfinal %}
<script src="{{ asset('static/js/swiper/swiper.js') }}"></script>
<script>
//- condición cuando se llega a la seccion del footer
$( window ).scroll(function(e) {
var altura = $('.footer').height();
if($(window).scrollTop() + $(window).height() > $(document).height()-altura) {
$('.barfixed').addClass('barfixed_hide');
}else{
$('.barfixed').removeClass('barfixed_hide');
}
});
$(function(){
changeImage('.homeChangeImages');
window.onresize = function(){
changeImage('.homeChangeImages');
};
var b1homeSwiper = new Swiper('.b1home_slider.swiper-container', {
loop: ($('.b1home_slider.swiper-container .swiper-slide').length > 1),
effect: 'fade',
fadeEffect: {
crossFade: true
},
speed: 1000,
autoplay: {
delay: 5000,
disableOnInteraction: false
},
pagination: {
el: '.b1home_pager',
clickable: true,
}
});
getBlogPosts();
function getBlogPosts() {
$.ajax({
url: '{{ path('get-blog-posts') }}',
type: 'get',
beforeSend: function () {
$('#b4_blogposts').hide();
},
success: function (data) {
if (data['success']) {
let posts = data['posts'];
if (posts.length > 0) {
let postsTopHtml = renderBlogPosts(posts);
$('#b4_content_posts').html(postsTopHtml);
$('#b4_blog_posts').show();
}
}
}
})
}
function renderBlogPosts($postsData) {
let posts = '';
$.each($postsData, function (i, v) {
posts += renderBlogPost(i + 1, v);
})
return posts;
}
function renderBlogPost(index, post) {
return '' +
'<a href="' + post['link'] + '" class="b4home_box">' +
' <figure class="b4home_portada" style="background-image:url(' + post['image'] + ');">' +
' </figure>' +
' <div class="b4home_info">' +
' <span class="b4home_info_title">Noticias</span>' +
' <h3 class="b4home_info_subtitle">' + post['title'] + '</h3>' +
' <div class="b4home_info_description">' +
' <p>' + $(post['excerpt']).text() + '</p>' +
' </div>' +
' <div class="b4home_info_team">' +
' <p>Equipo Eurocamiones</p>' +
' </div>' +
' <span class="b4home_info_date">' + post['createdat'] + '</span>' +
' </div>' +
'</a>';
}
});
</script>
{% endblock %}