MyBB Community Forums
[Need Help]Latest Threads on HomePage - Printable Version

+- MyBB Community Forums (https://community.mybb.com)
+-- Forum: Extensions (https://community.mybb.com/forum-201.html)
+--- Forum: Plugins (https://community.mybb.com/forum-73.html)
+---- Forum: Plugin Support (https://community.mybb.com/forum-72.html)
+---- Thread: [Need Help]Latest Threads on HomePage (/thread-10685.html)



[Need Help]Latest Threads on HomePage - livefooty - 2006-07-21

Hi,

How can I show one [Only The Newest] Thread On My homepage

my homepage is html file the forum is on /forum/


Thanks !!!


RE: [Need Help]Latest Threads on HomePage - Smethead - 2006-07-21

you can't do that on a normal html page. I advice you to copy the whole code into a phpfile and add this piece of code where you want to show the latest thread.
<?php
require "forum/global.php";
$query = mysql_query("SELECT * FROM ".TABLE_PREFIX."threads WHERE 1=1 ORDER BY dateline DESC LIMIT 0,1");
$thread = mysql_fetch_array($query);
echo '<a href="forum/showthread.php?tid='.$thread['tid'].'">'.$thread['subject'].'</a>';
?>

The part after echo is a normal html link. You can always change the html a bit, but I advice you to keep this link intact.


RE: [Need Help]Latest Threads on HomePage - livefooty - 2006-07-21

Thank You !!!
Working Great


RE: [Need Help]Latest Threads on HomePage - Michael S. - 2006-07-21

Please replace the query with the following so that drafts are not shown:
$query = mysql_query("SELECT * FROM ".TABLE_PREFIX."threads WHERE visible = '1' ORDER BY dateline DESC LIMIT 0,1");



RE: [Need Help]Latest Threads on HomePage - Jasper - 2006-07-22

Hmm, but this doesnt seem to work for me. My forum is on / but my site is on /kb and it won't link correctly. Can this be fixed?


RE: [Need Help]Latest Threads on HomePage - Michael S. - 2006-07-22

Replace the line
echo '<a href="forum/showthread.php?tid='.$thread['tid'].'">'.$thread['subject'].'</a>';
with
echo '<a href="http://www.your_url.tld/showthread.php?tid='.$thread['tid'].'">'.$thread['subject'].'</a>';
Replace http://www.your_url.tld/showthread.php with the real URL to your forums.


RE: [Need Help]Latest Threads on HomePage - Ragb - 2007-01-05

hello everybody,
I hope you are having a great new year start.
The above code is not working in my case.
it says

Direct initialization of this file is not allowed.

Please make sure IN_MYBB is defined.

what should I do ?