View Full Version : List Popular Threads on Another Page...
I was just wondering if there was a way to get vB to supply the 5 or 10 (or whatever) last posted to forum topics to another page (say the site index page).
I am curious because the only part of my site that uses PHP is vB, and the rest runs on Cold Fusion and HTML.
Can anyone help explain this?
<?
require("admin/config.php");
$num_active = 10;
$db=mysql_connect($servername,$dbusername,$dbpassw ord);
mysql_select_db($dbname);
$twentyfourhours= 24*60*60;
$date1 = time() - $twentyfourhours * 1;
$myselect = "select * from thread where lastpost > $date1 order by views desc limit 10";
$result = mysql_query($myselect);
if ($row = mysql_fetch_array($result)) {
do {
printf("<li><a href=\"http://www.gandmasti.com/forum/showthread.php?threadid=%d\">%s</a><br>%d views - %d replies</li>", $row[threadid], $row[title], $row[views], $row[replycount]);
} while ($row = mysql_fetch_array($result));
}
?>
What do I modify to make it list by replies instead? I dont want it to list views at all...
This will be for http://www.athlonoc.com
that works for pages not on your vbulletin
how would i add something like that to my vBulletin
like in my forumhome template
Vbulletin is NOT wanting me to SSI the pop topics in :(
http://www.athlonoc.com/vbulletin/index.php
check it out! it's actually putting in the <!--inlcude stuff...
Originally posted by krohn
Vbulletin is NOT wanting me to SSI the pop topics in :(
http://www.athlonoc.com/vbulletin/index.php
check it out! it's actually putting in the <!--inlcude stuff...
PHP != SHTML. Plain and simple.
use
<?php include("http://website.com"); ?>
instead
Originally posted by krohn
What do I modify to make it list by replies instead?
this would make it alot more efficient...
any ideas on how to list it by replies?
Use this code instead:
<?php
// Set this to the max number of threads to display
$maxthreads = 5;
require("config.php");
$db=mysql_connect($servername,$dbusername,$dbpassw ord);
mysql_select_db($dbname);
$query = "SELECT * FROM thread ORDER BY lastpost DESC LIMIT $maxthreads";
$resultlatest = mysql_query($query,$db);
while ($latest_array = mysql_fetch_array($resultlatest)) {
echo "<FONT SIZE=\"2\" FACE=\"Verdana, Arial, Helvetica, sans-serif\"> °
<A HREF=\"http://www.YourDomain.com/showthread.php?threadid=$latest_array[threadid]\">$latest_array[title]</A></FONT><BR>";
}
?>
thanx......but is there a way to display replies with this also?
i can get views to display...but not replies
<?php include("http://athlonoc.com/vbulletin/pop.php"); ?>
that didn't work :( Where I'm trying to put this is in the footer template. http://www.athlonoc.com/vbulletin/index.php it's on the right side. I'd like to include some things in the forum's template but I can't figure it out!
Did you make it so your footer will work with php?
$footer = include("http://athlonoc.com/vbulletin/pop.php");
and enable PHP adfooter in the control panel!
Correct if I am wrong. :)
Instead of listing the last 5/10 posts, I wanted to list the most popular threads for the month. Your subject says "popular", so in case you're interested in that too, here's the code I used to list the 5 most popular topics of the month on a different page. It is sorted by reply count and skips the private forums.
require("../bb/admin/config.php");
$num_active = 5;
$db=mysql_connect($servername,$dbusername,$dbpassw ord);
mysql_select_db($dbname);
$myselect = "SELECT * from thread where MONTH(FROM_UNIXTIME(lastpost))=MONTH(NOW()) AND YEAR(FROM_UNIXTIME(lastpost))=YEAR(NOW()) AND (forumid < 8 OR forumid > 10) order by replycount desc limit $num_active";
echo "<A NAME='#popular'>";
echo "<H3>This month's most popular board topics</H3>";
$result = mysql_query($myselect);
if ($row = mysql_fetch_array($result)) {
$counter=0;
do {
$counter=++$counter;
echo ("$counter. <a href=\"http://www.yourdomain.com/bb/showthread.php?threadid= $row[threadid]\">$row[title]</a> - $row[views] views - $row[replycount] replies<BR>");
} while ($row = mysql_fetch_array($result));
}
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.