UBB.Dev
Posted By: PhotoPost Current Threads - 08/20/2003 9:52 PM
Tweaking the query a bit, I change the format of the Current Threads. It now shows the threads which have been replied to most recently, the subject and how long ago since the reply was posted.

http://www.viperalley.com/summary.php?Cat=

If anyone likes it, I'll post the simple changes.
Posted By: AKD96 Re: Current Threads - 08/21/2003 3:57 PM
Groovy idea! And you might as well post the changes, because you know you're going to get swamped with posts!
Posted By: PhotoPost Re: Current Threads - 08/21/2003 6:06 PM
:lol: true.

Well, the changes are not too difficult - adds a LEFT JOIN to the query to get some additional info. One thing I did notice is the "new" threads dont have the username appearing, so am looking into how to do that without adding another query. For now I just post new threads without a username and nobody notices.
Posted By: ST Re: Current Threads - 10/21/2003 3:01 AM
ahem...

Exactly where are the "simple changes?"

I have searched Low but not high yet.. Hoped you could save me some time...
Posted By: PhotoPost Re: Current Threads - 01/05/2004 5:20 AM
Well, here's what I use:

Code
<?<br /><br />if ( $LastCacheTime == 0 || !$CurrentThreadsData ) {<br />   $boardq2 = str_replace("B_", "p.B_", $boardquery);<br />    <br />   $query = "<br />		SELECT p.B_Number,p.B_Posted,p.B_Last_Post,p.B_Subject,p.B_Main,p.B_Replies,p.B_Counter,p.B_Board,u.U_UserName,b.Bo_Title<br />		FROM  {$config['tbprefix']}Posts AS p<br />		LEFT JOIN {$config['tbprefix']}Boards AS b ON b.Bo_Keyword = p.B_Board<br />		LEFT JOIN {$config['tbprefix']}Users AS u ON u.U_Number = p.B_LastPosterId<br />		WHERE p.B_Number = p.B_Main<br />        AND (p.B_Sticky = 0 OR p.B_Sticky IS NULL)<br />        $boardq2<br />		ORDER BY p.B_Last_Post DESC<br />		LIMIT $totalcurrentthreads<br />   ";<br /><br />	$sth = $dbh -> do_query($query);<br /><br />	$c = 0;<br />    $curtime = $html -> get_date();	<br />	<br />	$myString = "$tbopen<tr><td align=\"center\" class=\"tdheader\">{$pal_CurrentThreads[0]}</td></tr><tr><td align=\"left\" valign=\"top\" class=\"lighttable\"><table width=\"100%\">";<br />	while ( list($palNumber,$palPosted,$palLast,$palSubject,$palMain,$palReplies,$palCounter,$palKeyword,$palPoster,$palBoTitle) = $dbh -> fetch_array($sth)) {<br />		$c++;<br />		$timepast = round(($curtime - $palLast)/60);<br />		if ( $timepast > 1 ) $timepast = "$timepast minutes ago";<br />		elseif ( $timepast == 1 ) $timepast = "$timepast minute ago";<br />		else  $timepast = "just now";<br />	<br />	    if ( !empty($palPoster) ) $palPoster = " by $palPoster";	<br />		if ( strlen($palSubject) > 30 ) $palSubject = substr($palSubject,0,30) . "...";<br />		<br />		$myString .= "<tr><td align=\"left\" valign=\"top\" class=\"lighttable\">$spacer</td><td align=\"left\" valign=\"top\" class=\"lighttable\"><font class=\"small\">$palBoTitle: <a href=\"{$config['phpurl']}/showflat.php/Cat/$Cat/Board/$palKeyword/Number/$palNumber\">$palSubject</a>$palPoster ($timepast)</font></td></tr>";<br />	}<br />	if ($c < 1) {$myString .= "<tr><td class=\"lighttable\">{$pal_CurrentThreads[1]}</td></tr>";}<br />	<br />	$myString .= "</table></td></tr>$tbclose<br />";<br />	$CurrentThreadsStorageString = $myString;<br />	$dbh -> finish_sth($sth);<br />}<br />else {<br />	$myString = $CurrentThreadsData;<br />	$CurrentThreadsStorageString = $CurrentThreadsData;<br />}<br /><br />echo $myString;<br />?>


But you should be warned ahead of time, this can be a hog. I finally set up a cronjob to rebuild my cache every 5 minutes because my summary page was taking 2-3 seconds to generate.

You can give it a try, but I dont know if I can recommend it.
Posted By: ST Re: Current Threads - 01/06/2004 6:25 AM
I copied the code precisely as entered there. It works great, until the link within is clicked to go to the referring topic. It then says "No input file specified."

I compared the link referrences in the old current threads to what you had psoted and saw a discrepancy. Your mod made the link look like "http://www.mysite.net/bomberjackets/showflat.php/Cat//Board/unearth/Number/10829"

where the old current threads made the link: "http://www.mysite.net/ashes/showflat.php?Cat=&Board=UBB1&Number=11025"

I highlighted the parts I think are causing the problem as all the other links on my site look like the second example.

I played around with it a but but cannot seem to remedy it. Any advice would be appreciated.
Posted By: ST Re: Current Threads - 01/06/2004 6:39 AM
OK... I figured it out.. sorry for the premature venting... now I have another error to discuss.... I will psot it elsewhere...

Again, thanks.
© UBB.Developers