|
Author |
Message |
BenPollinger
Junior WebHelper
Joined: 11 Aug 2006
Posts: 5
Location: Leeds
|
Posted:
Sun Aug 13, 2006 5:28 pm (17 years, 8 months ago) |
|
Hello,
Can you explain how you implemented the front page table for recent articles? I mean the table headed "Active Topics from our Forums"
Does it use your RSS feed or some other technique?
cheers,
Ben |
________________________________ www.pollinger.org.uk
www.psyclick.org.uk |
|
|
|
Daniel
Team Member
Joined: 06 Jan 2002
Posts: 2564
|
Posted:
Tue Aug 15, 2006 8:04 pm (17 years, 8 months ago) |
|
|
|
|
BenPollinger
Junior WebHelper
Joined: 11 Aug 2006
Posts: 5
Location: Leeds
|
Posted:
Tue Aug 15, 2006 8:25 pm (17 years, 8 months ago) |
|
|
|
|
BenPollinger
Junior WebHelper
Joined: 11 Aug 2006
Posts: 5
Location: Leeds
|
Posted:
Thu Aug 31, 2006 2:40 pm (17 years, 7 months ago) |
|
Hi Daniel,
I've got this working fine but could you tell me the php you use to get the time formatted in terms of mins/hours/days ago ?
thanks,
Ben |
________________________________ www.pollinger.org.uk
www.psyclick.org.uk |
|
|
|
Daniel
Team Member
Joined: 06 Jan 2002
Posts: 2564
|
Posted:
Thu Aug 31, 2006 3:59 pm (17 years, 7 months ago) |
|
Ben,
I used the following function (this isn't my own function, but I can't remember where I got it):
Code: | /* Works out the time since the entry post, takes a an argument in unix time (seconds) */
function time_since($original) {
// array of time period chunks
$chunks = array(
array(60 * 60 * 24 * 365 , 'year'),
array(60 * 60 * 24 * 30 , 'month'),
array(60 * 60 * 24 * 7, 'week'),
array(60 * 60 * 24 , 'day'),
array(60 * 60 , 'hour'),
array(60 , 'minute'),
);
$today = time(); /* Current unix time */
$since = $today - $original;
// $j saves performing the count function each time around the loop
for ($i = 0, $j = count($chunks); $i < $j; $i++) {
$seconds = $chunks[$i][0];
$name = $chunks[$i][1];
// finding the biggest chunk (if the chunk fits, break)
if (($count = floor($since / $seconds)) != 0) {
// DEBUG print "<!-- It's $name -->\n";
break;
}
}
$print = ($count == 1) ? '1 '.$name : "$count {$name}s";
if ($i + 1 < $j) {
// now getting the second item
$seconds2 = $chunks[$i + 1][0];
$name2 = $chunks[$i + 1][1];
// add second item if it's greater than 0
if (($count2 = floor(($since - ($seconds * $count)) / $seconds2)) != 0) {
$print .= ($count2 == 1) ? ', 1 '.$name2 : ", $count2 {$name2}s";
}
}
return $print;
} |
|
________________________________
|
|
|
|
|
|
You cannot post new topics in this forum. You cannot reply to topics in this forum. You cannot edit your posts in this forum. You cannot delete your posts in this forum. You cannot vote in polls in this forum.
|
Page generation time: 0.143325 seconds :: 18 queries executed :: All Times are GMT
Powered by phpBB 2.0
© 2001, 2002 phpBB Group :: Based on an FI Theme
| |