{% 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 %}
<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) }}"></figure>
<div class="b1home_info">
<div class="b1home_content ww_center">
{% if item.text %}
<h2 class="b1home_title">{{ item.text|nl2br }}</h2>
{% endif %}
{% if item.buttonShow and item.buttonLink %}
<div class="b1home_button">
<a href="{{ item.buttonLink }}" class="btn btn_lightblue" target="{{ item.buttonTarget|url_target }}">{{ item.buttonText ?: 'Ver más' }}</a>
</div>
{% endif %}
</div>
</div>
</div>
</li>
{% endfor %}
</ul>
<div class="b1home_pager"></div>
</div>
</section>
{% if sd.trucksShow or sd.busesShow %}
<section class="b2home">
<div class="b2home_content ww_center">
<div class="b2home_blocks">
{% if sd.trucksShow %}
<div class="b2home_itemblock">
<h2 class="b2home_title">{{ sd.trucksTitle ?: 'Camiones' }}</h2>
<div class="b2home_slider swiper-container">
<ul class="swiper-wrapper">
{% for item in trucks %}
<li class="b2home_itembox swiper-slide">
<a href="{{ path('model_detail', {'slug': item.slug}) }}" class="b2home_card">
<figure class="b2home_portada">
<img src="{{ asset(item.image|image_path) }}" width="250" height="160" alt="{{ item.title }}">
</figure>
<h3 class="b2home_subtitle">{{ item.title }}</h3>
<div class="b2home_btn">
<div class="btn btn_grayline" href="{{ path('model_detail', {'slug': item.slug}) }}">Más información</div>
</div>
</a>
</li>
{% endfor %}
</ul>
</div>
<div class="b2home_link">
<a class="btn btn_lightblue" href="{{ path('model_trucks') }}" target="{{ sd.trucksButtonTarget|url_target }}">{{ sd.trucksButtonTitle ?: 'MÁS MODELOS' }}</a>
</div>
</div>
{% endif %}
{% if sd.busesShow %}
<div class="b2home_itemblock">
<h2 class="b2home_title">{{ sd.busesTitle ?: 'Buses' }}</h2>
<div class="b2home_slider swiper-container">
<ul class="swiper-wrapper">
{% for item in buses %}
<li class="b2home_itembox swiper-slide">
<a href="{{ item.link|external_url }}" class="b2home_card">
<figure class="b2home_portada">
<img src="{{ asset(item.image|image_path) }}" width="250" height="160" alt="{{ item.title }}">
</figure>
<h3 class="b2home_subtitle">{{ item.title }}</h3>
<div class="b2home_btn">
<div class="btn btn_grayline" href="{{ item.link|external_url }}">Más información</div>
</div>
</a>
</li>
{% endfor %}
</ul>
</div>
<div class="b2home_link">
<a class="btn btn_lightblue" href="{{ path('model_buses') }}" target="{{ sd.busesButtonTarget|url_target }}">{{ sd.busesButtonTitle ?: 'MÁS MODELOS' }}</a>
</div>
</div>
{% endif %}
</div>
</div>
</section>
{% endif %}
{% if sd.detailShow %}
<section class="b3home">
<div class="b3home_content ww_center">
<div class="b3home_left">
{% if sd.detailText %}
<div class="b3home_description">
<p>{{ sd.detailText|nl2br }}</p>
</div>
{% endif %}
<div class="b3home_items">
{% for item in sd.detailOptions %}
<a href="{{ item.link }}" class="b3home_box">
<h3 class="b3home_subtitle">{{ item.title }}</h3>
<span class="b3home_number">{{ loop.index|str_pad(2, '0', constant('STR_PAD_LEFT')) }}</span>
</a>
{% endfor %}
</div>
</div>
{% if sd.detailImage|image_path %}
<figure class="b3home_portada" style="background-image:url('{{ asset(sd.detailImage|image_path) }}');"></figure>
{% endif %}
</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.showRoulette and info.rouletteBannerHome|image_path %}
<a href="{{ info.rouletteLink|external_url }}" target="{{ info.rouletteTarget|url_target }}" 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) {
const 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');
};
const 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,
}
});
const b2homeSwiperContain = $('.b2home_slider.swiper-container');
b2homeSwiperContain.each(function(){
const _this = $(this);
const b2homeSwiper = new Swiper(_this, {
slidesPerView: 4,
loop: ($(_this).find('.swiper-slide').length > 4),
speed: 1000,
breakpoints: {
1024: {
slidesPerView: 3,
loop: ($(_this).find('.swiper-slide').length > 3),
},
767: {
slidesPerView: 'auto',
loop: false
}
}
/*
autoplay: {
delay: 1500,
disableOnInteraction: false
},
navigation: {
prevEl: '.b2home_prev',
nextEl: '.b2home_next',
},
*/
});
});
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'] + '" target="_blank" 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 %}