Notícias com imagem na home
Snippet para criar notícias com imagens para serem exibidas na home.
{#
# Noticias com imagem
#}
{% for pages in pages.custom %}
{% if pages.info == "noticias" %}
<div class="section-notices">
<h2 class="title-section">
<a href="/loja/busca_noticias.php">
<span>Confira Nossas Notícias</span>
</a>
</h2>
<div class="noticias-content">
</div>
</div>
{% endif %}
{% endfor %} jQuery(function(){
setTimeout(function() {
document.getElementsByTagName("html")[0].getAttribute("data-store");
var s = "busca_noticias.php?loja=" + document.getElementsByTagName("html")[0].getAttribute("data-store") +'&'+ document.getElementsByTagName("html")[0].getAttribute("data-files")
, e = jQuery(".noticias-content");
jQuery.ajax({
url: s,
type: "GET",
dataType: "html",
contentType: "charset=iso-8859-1",
success: function(s) {
var t = s.replace(/src/g, 'src');
e.html('<div class="noticias">' + jQuery(t).find(".noticias").html() + "</div>"),
e.find("li").wrapInner('<div class="box-noticia"></div>').find('img').attr('width', '400').attr('height', '400'),
e.find(".noticias li:nth-child(n+5)").remove(),
e.find('.noticias li').length ? '' : jQuery('.section-notices').remove();
}
})
}, 400);
})Como usar
Copie o código HTML acima e insira no arquivo home.html onde desejar.
Para o arquivo JavaScript crie um novo arquivo na pasta JS e faça sua chamada conforme exemplo:
<script type="text/javascript" src="{{ asset('js/load-news.js') }}"></script>Last updated
Was this helpful?
