Back to vBulletin 4.x Add-ons

[WIDGET] Recent Threads
Mod Version: 1.00, by cory_booth

vB Version: 4.0.2 Rating: (13 votes - 4.77 average) Installs: 128
Released: 20 Feb 2010 Last Update: Never Downloads: 0
Not Supported Re-usable Code Is in Beta Stage  

In an attempt at mirroring an old ASP website I used to have, I modified the recent threads display to show a bit more information in a bit more compressed format.

Feel free to use/hack/slash this code for your own needs...

Navigate to AdminCP -> CMS -> Widgets.
Create a PHP Type Widget and paste the below code.

READ BELOW THE CODE FOR AN UPDATE

PHP Code:
ob_start();
global 
$vbulletin$db;
//Begin Thread Counts 
$toutput=''
$recent_threads $vbulletin->db->query_read(
SELECT thread.threadid, thread.title, thread.dateline, thread.lastpost, thread.lastposter, thread.lastposterid, thread.visible, thread.open, thread.postusername, thread.postuserid, thread.replycount, thread.views, forum.forumid, forum.title as forumtitle
FROM  " 
TABLE_PREFIX "thread AS thread 
LEFT JOIN  " 
TABLE_PREFIX "forum AS forum ON ( forum.forumid = thread.forumid ) 
WHERE NOT ISNULL(threadid) AND visible = '1' AND open!='10' 
ORDER BY lastpost DESC 
LIMIT 0, 10 
"
); 
$i 0
while (
$recent_thread $db->fetch_array($recent_threads)) 

$i++;
if (!
in_array($recent_thread[forumid], array(105,83,121,110,82,112,109,101,102,72))) { 
if (
$i 1) {$class='alt1';} else {$class='alt2';} 
$recent_thread[title] = unhtmlspecialchars($recent_thread[title]); 
$recent_thread[lastpostdate] = vbdate('M jS'$recent_thread[lastpost], 1); 
$recent_thread[lastposttime] = vbdate($vbulletin->options['timeformat'], $recent_thread[lastpost]); 
$toutput .='<tr><td class="'.$class.'" align="left"><b><font color="#98B5E2" size="1" face="verdana,arial"><a href="showthread.php?t='.    $recent_thread[threadid].'">'.    $recent_thread[title].'</a></font></b><br/>'
$toutput .='<b><span style="color: #E1E1E2"><font size="1" face="verdana,arial">Last Post By: <a href="member.php?u='.$recent_thread[lastposterid].'">'.$recent_thread[lastposter].'</a></font><br/></span></b>'
$toutput .='<font size="1" face="verdana,arial">Forum: <a href="forumdisplay.php?f='.$recent_thread[forumid].'">'.$recent_thread[forumtitle].'</a> | Replies: '.$recent_thread[replycount].'</font><br/>'
$toutput .='<font size="1" face="verdana,arial">Posted: <strong>'.$recent_thread[lastpostdate].'</strong> at: <strong>'.    $recent_thread[lastposttime].'</strong></font><hr/></td></tr>'

}
//End Thread Counts 

//Sidebar - Begin Forum Threads
$sb_threads '
<table class="tborder" cellpadding="'
.$stylevar[cellpadding].'" cellspacing="'.$stylevar[cellspacing].'" border="0" width="100%" align="center"> <thead> <tr> <td class="tcat"></td> </tr> </thead> <tbody> <div class="smallfont"> <tr> <td>
'
.$toutput.'
</td> </tr> </div> </tbody> </table>
'
;
//Sidebar - End Forum Threads
echo $sb_threads;
$db->free_result($recent_threads);
$output=ob_get_contents();
ob_end_clean(); 

Updated to reflect contribution from Inflikted:

Spoiler (click to open)


is there an easy way to block out private forums from this?

nevermind figured it out... for those others who wanted to know how

change
Code:
if (!in_array($recent_thread[forumid], array(105,83,121,110,82,112,109,101,102,72))) {
to the proper forumid's you would like to block
PHP Code:
ob_start(); 
global 
$vbulletin$db
//Begin Thread Counts 
$toutput=''
$recent_threads $vbulletin->db->query_read(
SELECT thread.threadid, thread.title, thread.dateline, thread.lastpost, thread.lastposter, thread.lastposterid, thread.visible, thread.open, thread.postusername, thread.postuserid, thread.replycount, thread.views, forum.forumid, forum.title as forumtitle
FROM  " 
TABLE_PREFIX "thread AS thread 
LEFT JOIN  " 
TABLE_PREFIX "forum AS forum ON ( forum.forumid = thread.forumid ) 
WHERE NOT ISNULL(threadid) AND visible = '1' AND open!='10' 
ORDER BY lastpost DESC 
LIMIT 0, 10 
"
); 
$i 0
while (
$recent_thread $db->fetch_array($recent_threads)) 

$i++;
if (!
in_array($recent_thread[forumid], array(105,83,121,110,82,112,109,101,102,72))) { 
if (
$i 1) {$class='alt1';} else {$class='alt2';} 
$recent_thread[title] = unhtmlspecialchars($recent_thread[title]); 
$recent_thread[lastpostdate] = vbdate('M jS'$recent_thread[lastpost], 1); 
$recent_thread[lastposttime] = vbdate($vbulletin->options['timeformat'], $recent_thread[lastpost]); 
$toutput .='<tr><td class="'.$class.'" align="left"><b><font color="#98B5E2" size="1" face="verdana,arial"><a href="showthread.php?t='.    $recent_thread[threadid].'">'.    $recent_thread[title].'</a></font></b><br/>'
$toutput .='<b><span style="color: #E1E1E2"><font size="1" face="verdana,arial">Last Post By: <a href="member.php?u='.$recent_thread[lastposterid].'">'.$recent_thread[lastposter].'</a></font><br/></span></b>'
$toutput .='<font size="1" face="verdana,arial">Forum: <a href="forumdisplay.php?f='.$recent_thread[forumid].'">'.$recent_thread[forumtitle].'</a> | Replies: '.$recent_thread[replycount].'</font><br/>'
$toutput .='<font size="1" face="verdana,arial">Posted: <strong>'.$recent_thread[lastpostdate].'</strong> at: <strong>'.    $recent_thread[lastposttime].'</strong></font><hr/></td></tr>'

}
//End Thread Counts 

//Sidebar - Begin Forum Threads 
$sb_threads 
<table class="tborder" cellpadding="'
.$stylevar[cellpadding].'" cellspacing="'.$stylevar[cellspacing].'" border="0" width="100%" align="center"> <thead> <tr> <td class="tcat"></td> </tr> </thead> <tbody> <div class="smallfont"> <tr> <td>
'
.$toutput.
</td> </tr> </div> </tbody> </table> 
'

//Sidebar - End Forum Threads 
echo $sb_threads
$db->free_result($recent_threads); 
$output=ob_get_contents(); 
ob_end_clean(); 

Close


Be SURE to update the following line:if (!in_array($recent_thread[forumid], array(105,83,121,110,82,112,109,101,102,72))), to group the forumids you wish to NOT have included in the query results.

Download

No files for download.

Screenshots

Click image for larger version
Name:	forum.jpg
Views:	5674
Size:	83.4 KB
ID:	112675  


vblts.ru supports vBulletin®, 2022-2024