PDA

View Full Version : Newest Posts on Main page


Zeus
03-17-2001, 10:36 AM
Is there a hack that lets you put the most recent posts in the forum on the main page of your site?

Where can I get it?

03-17-2001, 11:52 AM
I search too this hack :(

03-17-2001, 12:38 PM
I searched it in my last thread "help*_*", too.

Have nobody make one jet?

03-17-2001, 12:53 PM
I've seen this in action on Sitepoint (http://www.sitepoint.com) so it can be done.
How being the definitive question

03-17-2001, 04:44 PM
<?php
// Set this to the max number of threads to display
$maxthreads = 10;

require("./admin/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 "<a href=\"showthread.php?threadid=$latest_array[threadid]\">$latest_array[title]</a>";
}

?>

03-17-2001, 04:58 PM
Ratorasniki, do I just copy & paste that code onto my main html page to get these Topics to show up there?

03-17-2001, 05:12 PM
Firstly thanks for the help really aprreciate it.

i tried pasting the code into my page but it generated a parse error on the line with the SQL query on it.

03-17-2001, 05:14 PM
echo "<a href=\"http://www.yoursite.com/path_to_forum/showthread.php?threadid=$latest_array[threadid]\">$latest_array[title]</a><br>";

Change this and it works perfect. Thanks Ratorasniki *_*

03-17-2001, 05:17 PM
$servername="****";
$dbusername="****";
$dbpassword="****";
$dbname="****";

At this instead of "require("./admin/config.php");" Zeus.

03-17-2001, 05:27 PM
I tried that it still dosent work, again the error is with the SQL query statement.

I'm using php3 will that make a difference?
(I have made the necessary php3 extension changes)

03-17-2001, 05:39 PM
Use a PHP Include for this File in your Main Page and just change the Password stuff, etc.. in the file.

This have to work.

03-17-2001, 05:47 PM
yes thats worked, Excellent stuff

Danke
Thank you
Go raibh math agat.

03-17-2001, 06:14 PM
I don't get it guys.. I'm new to VBB modification.
I see all these neat things I can be using but I still don't know how to have this text come up on my page page..

Can someone please lay it out for me?
I've tried making these files and then linking to them by puttings this on my main page ( <!--#include virtual="/forums/online.php"--> )
But nothing works still.. What am I doing wrong?

03-17-2001, 06:16 PM
you can only include php code in a php page, which means it ends with either .php or .php3
a .shtml page can't execute php.

03-17-2001, 06:19 PM
Thx very much guys!!
That work very nice

03-17-2001, 06:20 PM
Ohh, OK. So how would I include that php code in a regular HTML page?

Or how can I convert my HTML page into PHP?

03-17-2001, 06:30 PM
You dont have to do anything with html.

First download the code MB posted

Make the changes as for your website and forum

Upload it to your root directory(if you want them to display on the main index page of your site)

Add this to your index page where you want the posts to appear:

<?php include('forum.txt');?>

Save it as index.php

03-17-2001, 08:12 PM
I finally got it.. thanks guys!

03-17-2001, 09:03 PM
It gives it to me in a big hunk tho?

http://form-kaos.com/forum/newthreads.php

Ideas on fixing?

03-17-2001, 09:20 PM
you need to include <br> in the echo thing

03-18-2001, 08:25 AM
If you use this, than all threads are shown on the mainpage, even threads that are in internal forums.

Is there a solution for this?

03-18-2001, 01:33 PM
very nice and easy to install.

Is there a way i could have the date of the post and the name of the poster + the title? like in http://www.sitepoint.com/

thank you in advance

03-18-2001, 01:40 PM
yes, that is the script that will solve all of our problems.
I have asked Wayne on their forums about it, but got no reply :(

03-18-2001, 02:57 PM
Originally posted by auto
you can only include php code in a php page, which means it ends with either .php or .php3
a .shtml page can't execute php.

Um, actually it will if you use a SSI. As long as your server supports PHP parsing, you can include a PHP file via SSI (see this (http://www.vbulletin.com/forum/showthread.php?s=&threadid=10932)). Also, you can use the extension of .phtml on PHP files, assuming your server supports this.

03-18-2001, 03:04 PM
Originally posted by TommyXXL
If you use this, than all threads are shown on the mainpage, even threads that are in internal forums.

Do you mean private forums that are limited access? If so, here's the solution. Change the line
$query = "SELECT * FROM thread ORDER BY lastpost DESC LIMIT $maxthreads";
to
$query = "SELECT * FROM thread WHERE forumid!=XX ORDER BY lastpost DESC LIMIT $maxthreads";
and change the XX to the number of the forum you want to exclude. (You can determine the forum number by going to your main forums page and mousing over the link to each forum. The forum number is the part of the url after forumid; e.g. http://yoursite.com/forumdisplay.php?s=&forumid=36. To exclude more than one forum, add this:
AND forumid!=XX
for each additional forum you want to exclude. MAKE SURE you add a space before the word AND and a space after XX and you change the XX to the number you want excluded. Example: I want to exclude forums 6, 12, and 35.
$query = "SELECT * FROM thread WHERE forumid!=6 AND forumid!=12 AND forumid!=35 ORDER BY lastpost DESC LIMIT $maxthreads";
Second example: I want to exclude forum 6.
$query = "SELECT * FROM thread WHERE forumid!=6 ORDER BY lastpost DESC LIMIT $maxthreads";

SVTBlackLight01
01-05-2003, 01:21 AM
Is there a way to get the user and date to display too.