4WebHelp
 FAQ  •  Search  •  User Groups  •  Forum Admins  •  Smilies List  •  Statistics  •  Rules   •  Login   •  Register
Toggle Navigation Menu

 Front page table for active topics
Post New TopicReply to Topic
View Previous Topic Print this topic View Next Topic
Author Message
BenPollinger
Junior WebHelper
Junior WebHelper


Joined: 11 Aug 2006
Posts: 5
Location: Leeds

PostPosted: Sun Aug 13, 2006 5:28 pm (17 years, 8 months ago) Reply with QuoteBack to Top

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
OfflineView User's ProfileFind all posts by BenPollingerSend Personal MessageVisit Poster's Website
Daniel
Team Member



Joined: 06 Jan 2002
Posts: 2564

PostPosted: Tue Aug 15, 2006 8:04 pm (17 years, 8 months ago) Reply with QuoteBack to Top

We're using the following phpBB script:

http://www.matthijs.net/downloads/tools/active_topics.phps

However there are many others available on phpBB.com - this is simply the one we selected.

________________________________
Image
OfflineView User's ProfileFind all posts by DanielSend Personal Message
BenPollinger
Junior WebHelper
Junior WebHelper


Joined: 11 Aug 2006
Posts: 5
Location: Leeds

PostPosted: Tue Aug 15, 2006 8:25 pm (17 years, 8 months ago) Reply with QuoteBack to Top

THanks Daniel, that looks pretty straightforward compared to some of the RSS things I was looking at.

cheers,
Ben

________________________________
www.pollinger.org.uk
www.psyclick.org.uk
OfflineView User's ProfileFind all posts by BenPollingerSend Personal MessageVisit Poster's Website
BenPollinger
Junior WebHelper
Junior WebHelper


Joined: 11 Aug 2006
Posts: 5
Location: Leeds

PostPosted: Thu Aug 31, 2006 2:40 pm (17 years, 7 months ago) Reply with QuoteBack to Top

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
OfflineView User's ProfileFind all posts by BenPollingerSend Personal MessageVisit Poster's Website
Daniel
Team Member



Joined: 06 Jan 2002
Posts: 2564

PostPosted: Thu Aug 31, 2006 3:59 pm (17 years, 7 months ago) Reply with QuoteBack to Top

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;
}

________________________________
Image
OfflineView User's ProfileFind all posts by DanielSend Personal Message
Display posts from previous:      
Post New TopicReply to Topic
View Previous Topic Print this topic View Next Topic


 Jump to:   




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.121997 seconds :: 18 queries executed :: All Times are GMT
Powered by phpBB 2.0 © 2001, 2002 phpBB Group :: Based on an FI Theme