Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Re: # of posts since last visit
mrtunes wrote:
ok will do matt! to make things more interesting i’m planning doing a red little circle over the blog link on my navbar, like an iphone push notification. it will just have the number, and then on rollover it will expand a little to explain that’s how many posts since last visit.
You could use jQuery to check periodically to see if there’s been a new article and add the notification on the fly. I can’t get adi_calc working within rah_external_output though, otherwise I’d throw an example together.
Piwik Dashboard, Google Analytics Dashboard, Minibar, Article Image Colorpicker, Admin Datepicker, Admin Google Map, Admin Colorpicker
Offline
Re: # of posts since last visit
MattD wrote:
You could use jQuery to check periodically to see if there’s been a new article and add the notification on the fly. I can’t get adi_calc working within rah_external_output though, otherwise I’d throw an example together.
It works fine :-) Adi_calc just needs to load before rah_external_output.
Offline
Re: # of posts since last visit
Useing rah_external output create an output containing
<txp:variable name="articleCount" value="0" /><txp:article_custom limit="99999"><txp:adi_calc name="articleCount" add="1"/></txp:article_custom><txp:variable name="articleCount"/>
Then in your page or form you can use the following javascript to check the external output and update a dom node with the number of new articles. I used the jquery plugin periodicalupdater.
<txp:variable name="articleCount" value="0" /><txp:article_custom limit="99999"><txp:adi_calc name="articleCount" add="1"/></txp:article_custom>var currentCount=<txp:variable name="articleCount"/>;
$.PeriodicalUpdater('/?rah_external_output=article_count', {
method: 'get', // method; get or post
minTimeout: 1000, // starting value for the timeout in milliseconds
maxTimeout: 8000, // maximum length of time between requests
multiplier: 2, // if set to 2, timerInterval will double each time the response hasn't changed (up to maxTimeout)
type: 'text', // response type - text, xml, json, etc. See $.ajax config options
maxCalls: 0, // maximum number of calls. 0 = no limit.
autoStop: 0 // automatically stop requests after this many returns of the same data. 0 = disabled.
}, function(data) {
// Update the div if there are new articles (only called when there was a change)
if (data>currentCount){
$('#count').html(data-currentCount);
}
});
Piwik Dashboard, Google Analytics Dashboard, Minibar, Article Image Colorpicker, Admin Datepicker, Admin Google Map, Admin Colorpicker
Offline