To use this website completely, it is necessary to store cookies on your computer.
 

* Navigator

Expand - Collapse

* Statistic

  • *Total Posts: 14942
  • *Total Topics: 2271
  • *Online Today: 12
  • *Most Online: 292
(2016 November 12, 09:37:31 am)

Ajax recent posts.

Started by laric, 2009 March 30, 09:58:48 am

previous topic - next topic

0 Members and 0 Guests are viewing this topic.

laric

2009 March 30, 09:58:48 am
I have started to use a little ajax on my frontpage to make more of the frontpage auto refresh.

Here is a sample recent posts block that I use.


"$(document).everyTime(300000, function(i) {  updateLastposts();}, 0);" controls how often the block is autorefreshed.


This uses jquery and jquery.timers

http://www.jquery.com and http://plugins.jquery.com/project/timers

Put this in a script block
Code Select

<div id="latestpostsajax" class="content"></div>
<script type="text/javascript" src="/jquery-1.3.min.js"></script>
<script type="text/javascript" src="/jquery.timers.js"></script>
<script type="text/javascript">
$(document).ready(function(){
var messageList = $("#latestpostsajax");

function updateLastposts(){
messageList.hide();
$.ajax({
type: "POST", url: "/recentposts.php", data: "action=update",
complete: function(data){
messageList.html(data.responseText);
messageList.fadeIn(2000);
}
});
}

updateLastposts();

$(document).everyTime(300000, function(i) {  updateLastposts();}, 0);
});
</script>


Put this in /recentposts.php
Code Select

<?php 
require("SSI.php");
$myarray ssi_recentTopics(5null'array');
global 
$settings
foreach (
$myarray as $value) {
    echo 
"{$value[link]}<br/>".($value['new'] ? '' '<a href="' $scripturl '?topic=' $value['topic'] . '.msg' $value['new_from'] . ';topicseen#new" rel="nofollow"><img src="' $settings['lang_images_url'] . '/new.gif" border="0" /></a> '
.
"by {$value[poster][link]}<br/>{$value[time]}<br/><hr />";
}
 
?>
 


laric

#1
2009 April 03, 06:35:10 pm
I have done my own shoutbox instead of the one provided by portamx.

Guess I could clean up the spaghetti code and post it here.

I might do this over the easter holiday.

Dylert

#2
2013 August 23, 01:45:28 am
Quote from: laric ,  2009 March 30, 09:58:48 am
I have started to use a little ajax on my frontpage to make more of the frontpage auto refresh.

Here is a sample recent posts block that I use.


"$(document).everyTime(300000, function(i) {  updateLastposts();}, 0);" controls how often the block is autorefreshed.


This uses jquery and jquery.timers

http://www.jquery.com and http://plugins.jquery.com/project/timers

Put this in a script block
Code Select

<div id="latestpostsajax" class="content"></div>
<script type="text/javascript" src="/jquery-1.3.min.js"></script>
<script type="text/javascript" src="/jquery.timers.js"></script>
<script type="text/javascript">
$(document).ready(function(){
var messageList = $("#latestpostsajax");

function updateLastposts(){
messageList.hide();
$.ajax({
type: "POST", url: "/recentposts.php", data: "action=update",
complete: function(data){
messageList.html(data.responseText);
messageList.fadeIn(2000);
}
});
}

updateLastposts();

$(document).everyTime(300000, function(i) {  updateLastposts();}, 0);
});
</script>


Put this in /recentposts.php
Code Select

<?php 
require("SSI.php");
$myarray ssi_recentTopics(5null'array');
global 
$settings
foreach (
$myarray as $value) {
    echo 
"{$value[link]}<br/>".($value['new'] ? '' '<a href="' $scripturl '?topic=' $value['topic'] . '.msg' $value['new_from'] . ';topicseen#new" rel="nofollow"><img src="' $settings['lang_images_url'] . '/new.gif" border="0" /></a> '
.
"by {$value[poster][link]}<br/>{$value[time]}<br/><hr />";
}
 
?>
 



Is it still possible to use this? The post is written in 2009 and it would have been lovely to have an Ajax version of Recent topics! :)