Page 1 of 1

news infinite scroll

Posted: Sun Jan 04, 2015 10:06 am
by huner
Hallo,
sorry for my bad english.

I try to use infinite scroll on news, I found a script and i put it in the summary template, but i dont know how to change the foreach code, can someone help me please...

<__script__ type="text/javascript" src="js/jquery.min.js"></__script>
{literal}
var is_loading = false; // initialize is_loading by false to accept new loading
var limit = 4; // limit items per page
$(function() {
$(window).scroll(function() {
if($(window).scrollTop() + $(window).height() == $(document).height()) {
if (is_loading == false) { // stop loading many times for the same page
// set is_loading to true to refuse new loading
is_loading = true;
// display the waiting loader
$('#loader').show();
// execute an ajax query to load more statments
$.ajax({
url: 'load_more.php',
type: 'POST',
data: {last_id:last_id, limit:limit},
success:function(data){
// now we have the response, so hide the loader
$('#loader').hide();
// append: add the new statments to the existing data
$('#items').append(data);
// set is_loading to false to accept new loading
is_loading = false;
}
});
}
}
});
});
{/literal}

<ul id="items">
<?php
$last_id = 0;
foreach ($list as $rs) {
$last_id = $rs['id']; // keep the last id for the paging
?>
<li>
<a href="{$entry->moreurl}" title="{$entry->title|cms_escape:htmlall}">{$entry->title|cms_escape}</a>
</li>
<?php
}
?>
<__script__ type="text/javascript">var last_id = <?php echo $last_id; ?>;</__script>
</ul>

Re: news infinite scroll

Posted: Sun Jan 04, 2015 10:58 pm
by Dr.CSS
If you want a scroller like ones used on images that scroll past one after the other you can use something as simple as the jquery cycle plugin...

You may need to limit the amount of data per div, but here you go...

http://how-i-did-that.com/cgblog/3/15/S ... oller.html

Re: news infinite scroll

Posted: Mon Jan 05, 2015 8:46 am
by velden
Read this http://calguy1000.com/Blogs/9/60/jquery ... -news.html

You need to know how ajax works and how to create the proper urls. Though it might work with the already available 'next' urls.