PDA

View Full Version : List Popular Threads on Another Page...


11-01-2000, 09:32 PM
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?

11-05-2000, 02:01 AM
<?

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

11-13-2000, 09:42 PM
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

11-25-2000, 07:21 AM
that works for pages not on your vbulletin

how would i add something like that to my vBulletin

like in my forumhome template

11-27-2000, 05:43 AM
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...

11-27-2000, 12:19 PM
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.

11-27-2000, 09:00 PM
so uhh... what do I do?

11-28-2000, 03:25 PM
use

<?php include("http://website.com"); ?>

instead

11-30-2000, 12:27 PM
Originally posted by krohn
What do I modify to make it list by replies instead?

this would make it alot more efficient...

12-05-2000, 04:43 PM
any ideas on how to list it by replies?

12-06-2000, 05:09 AM
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\">&nbsp;°
<A HREF=\"http://www.YourDomain.com/showthread.php?threadid=$latest_array[threadid]\">$latest_array[title]</A></FONT><BR>";
}

?>

12-06-2000, 04:52 PM
thanx......but is there a way to display replies with this also?

i can get views to display...but not replies

12-28-2000, 02:29 PM
<?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!

12-29-2000, 12:30 PM
Did you make it so your footer will work with php?

12-29-2000, 01:11 PM
$footer = include("http://athlonoc.com/vbulletin/pop.php");

and enable PHP adfooter in the control panel!


Correct if I am wrong. :)

12-30-2000, 12:25 PM
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));
}