Jump to content
Sign in to follow this  
OpenClose

Lazy Load для товаров на главной странице магазина

Recommended Posts

Всем привет столкнулся с проблемой  Lazy Load, пытаюсь подключить к шаблону темы [/size]catalog\view\theme\theme\template\module\viewed.tpl, который выводит на главную 

Категория

 

Товары

 

 

Категория

 

Товары

 

 

Категория

 

Товары

 

подключил

 <script src="jquery.lazyload.js" type="text/javascript"></script>
$(function() {
$("carousel-inner box-content").lazyload();
});
вот сам шаблон:

<?php if (count($products) > 0) { ?>

<script type="text/javascript">

if ($('.container').width() > 723) {

(function($){$.fn.equalHeights=function(minHeight,maxHeight){tallest=(minHeight)?minHeight:0;this.each(function(){if($(this).height()>tallest){tallest=$(this).height()}});if((maxHeight)&&tallest>maxHeight)tallest=maxHeight;return this.each(function(){$(this).height(tallest)})}})(jQuery)

$(window).load(function(){

if($(".maxheight-feat").length){

$(".maxheight-feat").equalHeights()}

});

};

</script>

<? foreach($products as $index => $products_list){ ?>

<!-- slider-box-broduct 1 -->

<div id="slider-box-product-viewed-<?php echo $index; ?>" class="carousel slide box featured" data-ride="carousel">

<h2 title="<?php echo $h2_title[$index]; ?>" _t="<?='text_h2alt_'.$index?>"><?php echo $heading_title[$index]; ?></h2>

<div class="carousel-inner box-content">

<?php $i=0; foreach ($products_list1 as $product) { $i++ ?>

<?php

$perLine = 4;

$spanLine = 3;

$last_line = "";

$total = count($products);

$totModule = $total%$perLine;

if ($totModule == 0) { $totModule = $perLine;}

if ( $i > $total - $totModule) { $last_line = " last_line";}

if ($i%$perLine==1) {

$a='first-in-line';

?>

<div class="item box-product<?php echo ($i==1)?' active':'';?>">

<ul class="row">

<?php

}

elseif ($i%$perLine==0) {

$a='last-in-line';

}

else {

$a='';

}

?>

<li class="<?php echo $a. $last_line ;?> span<?php echo $spanLine ;?>">

<div class="image2">

<?php if ($product['sale'] && !$product['new'] && $product['special'] != 0) { ?>

<div class="discount-tag3"><div data-test="<?=round((1-($product['price']/$product['special']))*100)?>" data-price="<?=$product['price']?>" data-special="<?=$product['special']?>"><?php echo abs($product['sale']); ?><span>%</span></div></div>

<?php } ?>

<?php if ($product['new']) { ?>

<div class="new-tag-<?php echo $language_code ?>"></div>

<?php } ?>

<?php if ($product['thumb']) { ?><a href="<?php echo $product['href']; ?>" class="pimgbox"><img id="img_<?php echo $product['product_id']; ?>" src="<?php echo $product['thumb']; ?>" alt="<?php echo $product['name']; ?>" /></a><?php } ?>

<div class="qick-dtls">

<a href="<?php echo $product['href']; ?>" rel="colorbox" class="colorbox colorbox-<?php echo $index; ?>-viewed-<?php echo $i?> cboxElement">

<i class="fa fa-search"></i> <?php echo $text_quick; ?>

</a>

<a href="<?php echo $product['href']; ?>" class="clrbox2"><i class="fa fa-eye"></i> <?php echo $button_details; ?></a>

</div>

</div>

<div style="display:none;">

<div class="quick-view-<?php echo $index; ?>-viewed-<?php echo $i?> preview">

<div class="wrapper marg row-fluid">

<div class="left span4">

<?php if ($product['thumb1']) { ?>

<div class="image3">

<a href="<?php echo $product['href']; ?>"><img src="<?php echo $product['thumb1']; ?>" alt="<?php echo $product['name']; ?>" /></a>

</div>

<?php } ?>

</div>

<div class="right span8">

<h2><?php echo $product['name']; ?></h2>

<div class="inf">

<?php if ($product['author']) {?>

<span class="manufacture"><?php echo $text_manufacturer; ?> <a href="<?php echo $product['manufacturers'];?>"><?php echo $product['author']; ?></a></span>

<?php }?>

<?php if ($product['model']) {?>

<span class="model"><?php echo $text_model; ?><?php echo $product['model']; ?></span>

<?php }?>

<span class="prod-stock-2"><?php echo $text_availability; ?></span>

<?php

if ($product['text_availability'] > 0) { ?>

<span class="prod-stock"><?php echo $text_instock; ?></span>

<?php } else { ?>

<span class="prod-stock"><?php echo $text_outstock; ?></span>

<?php

}

?>

<?php if ($product['price']) { ?>

<div class="price">

<span class="text-price"><?php echo $text_price; ?></span>

<?php if (!$product['special']) { ?>

<?php echo $product['price']; ?>

<?php } else { ?>

<span class="price-new"><?php echo $product['price']; ?></span><span class="price-old"><?php echo $product['special']; ?></span>

<?php } ?>

</div>

<?php } ?>

</div>

<div class="cart-button">

<div class="cart">

<a title="<?php echo $button_cart; ?>" data-id="<?php echo $product['product_id']; ?>;" class="button addToCart-1 ">

<!--<i class="icon-shopping-cart"></i>-->

<span><?php echo $button_cart; ?></span>

</a>

</div>

<a href="<?php echo $product['href']; ?>" class="button details"><span><?php echo $button_details; ?></span></a>

<div class="wishlist">

<a class="tooltip-1" title="<?php echo $button_wishlist; ?>" onclick="addToWishList('<?php echo $product['product_id']; ?>');">

<i class="icon-star"></i>

<span><?php echo $button_wishlist; ?></span>

</a>

</div>

<div class="compare">

<a class="tooltip-1" title="<?php echo $button_compare; ?>" onclick="addToCompare('<?php echo $product['product_id']; ?>');">

<i class="fa fa-bar-chart-o"></i>

<span><?php echo $button_compare; ?></span>

</a>

</div>

<span class="clear"></span>

</div>

<div class="clear"></div>

<div class="rating">

<img height="18" src="catalog/view/theme/theme316/image/stars-<?php echo $product['rating']; ?>.png" alt="<?php echo $product['reviews']; ?>" />

</div>

</div>

</div>

<div class="description">

<?php /*echo $product['description']; */ ?>

</div>

</div>

</div>

<a href="<?php echo $product['href']; ?>" class="colorbox-<?php echo $index; ?>-viewed-<?php echo $i?> quick-view-button"><i class="fa fa-search"></i></a>

<div class="inner">

<div class="f-left">

<div class="name maxheight-feat"><a href="<?php echo $product['href']; ?>"><?php echo $product['name']; ?></a></div>

<?php if ($product['price']) { ?>

<div class="price">

<?php if (!$product['special']) { ?>

<?php echo $product['price']; ?>

<?php } else { ?>

<span class="price-new"><?php echo $product['price']; ?></span><span class="price-old"><?php echo $product['special']; ?></span>

<?php } ?>

</div>

<?php } ?>

<!--<?php if ($product['description']) {?>

<div class="description"><?php echo mb_substr($product['description1'],0,60,'UTF-8').'...';?></div>

<?php } ?>-->

</div>

<div class="cart-button">

<div class="cart"><a title="<?php echo $button_cart; ?>" data-id="<?php echo $product['product_id']; ?>;" class="button addToCart"><!--<i class="icon-shopping-cart"></i>--><span><?php echo $button_cart; ?></span></a></div>

<!--<a href="<?php echo $product['href']; ?>" class="button details"><span><?php echo $button_details; ?></span></a>

<div class="compare"><a class="tooltip-1" title="<?php echo $button_compare; ?>" onclick="addToCompare('<?php echo $product['product_id']; ?>');"><i class="icon-bar-chart"></i><span><?php echo $button_compare; ?></span></a></div>

<div class="wishlist"><a class="tooltip-1" title="<?php echo $button_wishlist; ?>" onclick="addToWishList('<?php echo $product['product_id']; ?>');"><i class="icon-star"></i><span><?php echo $button_wishlist; ?></span></a></div>-->

<span class="clear"></span>

</div>

<div class="clear"></div>

<?php if ($product['rating']) { ?>

<div class="rating">

<img height="13" src="catalog/view/theme/theme316/image/stars-<?php echo $product['rating']; ?>.png" alt="<?php echo $product['reviews']; ?>" />

</div>

<?php } ?>

</div>

<div class="clear"></div>

</li>

<?php

if ($i%$perLine==0) {

?>

</ul>

</div>

<?php }?>

<?php } ?>

<?php

if ($i%$perLine!=0) {

?>

</ul>

</div>

<?php }?>

</div>

</div>

<?php } ?>

<?php } ?>

 

Товары грузится сразу, элемены не подгружаются с задержкой , кто нибудь моет подсказать как правильно подключить в этот код Лейзи Лоад прелоадинг для товаров

Share this post


Link to post
Share on other sites

Этот LazyLoad применим только к изображениям, если бы все было так легко, то я бы сейчас это не писал. 

Share this post


Link to post
Share on other sites

возможна ли такая загрузка для дивов?

 

В программировании все возможно, но целесообразно ли? 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
You are posting as a guest. If you have an account, please sign in.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×

Important Information

On our site, cookies are used and personal data is processed to improve the user interface. To find out what and what personal data we are processing, please go to the link. If you click "I agree," it means that you understand and accept all the conditions specified in this Privacy Notice.