Hi, I’m using jQuery AJAX to page through a list of news items, very simple. i’m a bit of a newbie, so not sure if there’s a way to get the total number of news items.
My template which retrieves a single news item is called “index_news_items”:
{exp:weblog:entries weblog="news" orderby="date" sort="desc" limit="1" offset="{segment_2}" show_future_entries="no" dynamic="off" disable="member_data|pagination|trackbacks"}
{title}
{entry_date format="%g:%i%a %l %j%S %F %Y"}
{news_article}
{/exp:weblog:entries}That gets loaded into a page which also has a “More news” button. Here’s the javascript jQuery which runs when the button is clicked:
var newsOffset = 0;
$(function($) {
$('.main .news .more a.link').click(function(){
newsOffset++;
$('#newsAjaxWrapper').load('/index_news_items/'+newsOffset);
return false;
});
});This works *perfectly*, but you can see there’s no way to know when there are no more news items left to display (so that i could disable the More button).
The {total_results} tag isn’t any good, since it’s affected by the “limit” variable. Can anyone suggest a neat way of getting the total number of news items?
thanks!