news infinite scroll

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
huner
New Member
New Member
Posts: 2
Joined: Sun Jan 04, 2015 9:16 am

news infinite scroll

Post 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>
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12711
Joined: Thu Mar 09, 2006 5:32 am

Re: news infinite scroll

Post 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
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3497
Joined: Mon Nov 28, 2011 9:29 am

Re: news infinite scroll

Post 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.
Post Reply

Return to “Modules/Add-Ons”