06-25-2000, 02:30 PM
Hello everyone-
This isn't as much a "vBulletin Hack" as it is, an "already existing hack hack". I based it on Krucifyx's active threads hack, but I cleaned it up with some code that I stole from Wanderer's Active Topic hack.
Basically, it is a stripped down version, which just displays the currently active topics, and the amount of replies. No icons, user names, or post info. I did this so that it would be easier to embed in an already existing page, like an index page, instead of having to use a totally separate page just for the active topics.
I only wanted it to take posts from one forum, and only display the last five active topics. The forum number can be changed, as can the amount of posts. Maybe someone could rework it to display multiple forums easily. Otherwise I guess you could implement multiple instances of the code.
Anyway, on to the good stuff:
Here is a working example:
http://www.bronx-bombers.com/index.php
And here is the code:
<?
include("forums/admin/config.php");
// The variables
$fontface = "arial";
$forumfontsize = "2";
$fontsize = "1";
$tablewidth = "100%";
print "<table border=0 width=$tablewidth cellspacing=3 cellpadding=3>\n";
if (!$topics) {
$topics = "5";
}
/*
################################################## ############################
# Lets Setup and Connect to the Database #
################################################## ############################
*/
$db=mysql_connect($servername,$dbusername,$dbpassw ord);
mysql_select_db($dbname);
// Lets find out how many forums there are
$forumquery = "select * from forum where forumid=5";
$forumresult = mysql_query($forumquery);
$forumcount = mysql_numrows($forumresult);
while($row = mysql_fetch_object($forumresult)) {
if ($row->active == "1") {
// Now lets find the latest threads
$threadquery = "select * from thread where forumid=5 order by lastpost desc limit 0,$topics";
$threadresult = mysql_query($threadquery);
$threadcount=mysql_numrows($threadresult);
if ($threadcount == "0") {
print "<tr><td colspan=3><font face=\"$fontface\" size=\"$fontsize\">No Posts yet. <a href=forumdisplay.php?forumid=5>";
print "Click here</a> to be the first!</font></td></tr>\n";
} // End if declaration
else {
while($row = mysql_fetch_object($threadresult)) {
if ($row->replycount == "0") {
$row->replycount = "No Replies";
}
elseif ($row->replycount == "1") {
$row->replycount = "1 Reply";
}
else {
$row->replycount = "$row->replycount Replies";
}
print " <tr>\n";
print " <td width=\"75%\" valign=\"top\">$TDColor<font face=\"$fontface\" size=\"$fontsize\"><a href=showthread.php?threadid=$row->threadid>$row->title</a></font></td>\n";
print " <td align=\"right\" width=\"25%\" valign=\"top\"><font face=\"$fontface\"size=\"$fontsize\">$row->replycount</font></td>\n";
print " </tr>\n";
}
} // End else declaration
} // End if declaration
} // End while loop
mysql_close();
?>
There are two instances of the forum number that you want to use, in the example code it is #5. Other than that, it is pretty self explanitory. Just stick it somewhere in a php file, and there you go.
My thanks go to Krucifx and Wanderer for letting me use their code to make it do what I wanted it to do. I can't take any credit (or responsibility :p) for the coding, since all I did was modify the code that they made.
Just thought I'd make my first *real* contribution to the community, despite how tiny it is.
-jim
[Edited by JimF on 06-25-2000 at 11:36 PM]
This isn't as much a "vBulletin Hack" as it is, an "already existing hack hack". I based it on Krucifyx's active threads hack, but I cleaned it up with some code that I stole from Wanderer's Active Topic hack.
Basically, it is a stripped down version, which just displays the currently active topics, and the amount of replies. No icons, user names, or post info. I did this so that it would be easier to embed in an already existing page, like an index page, instead of having to use a totally separate page just for the active topics.
I only wanted it to take posts from one forum, and only display the last five active topics. The forum number can be changed, as can the amount of posts. Maybe someone could rework it to display multiple forums easily. Otherwise I guess you could implement multiple instances of the code.
Anyway, on to the good stuff:
Here is a working example:
http://www.bronx-bombers.com/index.php
And here is the code:
<?
include("forums/admin/config.php");
// The variables
$fontface = "arial";
$forumfontsize = "2";
$fontsize = "1";
$tablewidth = "100%";
print "<table border=0 width=$tablewidth cellspacing=3 cellpadding=3>\n";
if (!$topics) {
$topics = "5";
}
/*
################################################## ############################
# Lets Setup and Connect to the Database #
################################################## ############################
*/
$db=mysql_connect($servername,$dbusername,$dbpassw ord);
mysql_select_db($dbname);
// Lets find out how many forums there are
$forumquery = "select * from forum where forumid=5";
$forumresult = mysql_query($forumquery);
$forumcount = mysql_numrows($forumresult);
while($row = mysql_fetch_object($forumresult)) {
if ($row->active == "1") {
// Now lets find the latest threads
$threadquery = "select * from thread where forumid=5 order by lastpost desc limit 0,$topics";
$threadresult = mysql_query($threadquery);
$threadcount=mysql_numrows($threadresult);
if ($threadcount == "0") {
print "<tr><td colspan=3><font face=\"$fontface\" size=\"$fontsize\">No Posts yet. <a href=forumdisplay.php?forumid=5>";
print "Click here</a> to be the first!</font></td></tr>\n";
} // End if declaration
else {
while($row = mysql_fetch_object($threadresult)) {
if ($row->replycount == "0") {
$row->replycount = "No Replies";
}
elseif ($row->replycount == "1") {
$row->replycount = "1 Reply";
}
else {
$row->replycount = "$row->replycount Replies";
}
print " <tr>\n";
print " <td width=\"75%\" valign=\"top\">$TDColor<font face=\"$fontface\" size=\"$fontsize\"><a href=showthread.php?threadid=$row->threadid>$row->title</a></font></td>\n";
print " <td align=\"right\" width=\"25%\" valign=\"top\"><font face=\"$fontface\"size=\"$fontsize\">$row->replycount</font></td>\n";
print " </tr>\n";
}
} // End else declaration
} // End if declaration
} // End while loop
mysql_close();
?>
There are two instances of the forum number that you want to use, in the example code it is #5. Other than that, it is pretty self explanitory. Just stick it somewhere in a php file, and there you go.
My thanks go to Krucifx and Wanderer for letting me use their code to make it do what I wanted it to do. I can't take any credit (or responsibility :p) for the coding, since all I did was modify the code that they made.
Just thought I'd make my first *real* contribution to the community, despite how tiny it is.
-jim
[Edited by JimF on 06-25-2000 at 11:36 PM]