MyBB Community Forums

Full Version: Display posts on homepage?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Is there any way to pull threads and articles from a specific forum to a static homepage? Like the one is SMF (ssi.php)..
You can use portal.php to pull threads from specified forums.
Ummmm yea. I want to pull posts like in portal.php but in altogether different page that i have made. It's like a custom homepage that sits entirely out of the forum software. If there's a way to use queries to pull from portal.php, please enlighten me.
simple method :
<?php
define("IN_MYBB", 1);
require_once("./global.php"); // Change this if needed
$tlimit = 20; // How many titles you want

$query = $db->query("SELECT * FROM ".TABLE_PREFIX."threads ORDER BY `tid` DESC LIMIT $tlimit");
while($fetch = $db->fetch_array($query)){
echo '<a href="./showthread.php?tid='.$fetch['tid'].'">'.$fetch['subject'].'</a><br />' . "\n";
}
?>
Better to use
get_thread_link($fetch['tid'])
instead
./showthread.php?tid='.$fetch['tid'].'
This'll work in both cases, either SEF or SEO pattern URLs.
^ oh! Thank You Smile
Thanks all Smile . But this will show list of topics, right? How would I go about displaying the post contents? Just the initial post, not the replies.
(2011-12-18, 02:06 PM)milliriba Wrote: [ -> ]Thanks all Smile . But this will show list of topics, right? How would I go about displaying the post contents? Just the initial post, not the replies.

Replace all the above code with this;
<?php
define("IN_MYBB", 1);
require_once("./global.php"); // Change this if needed
$tlimit = 20; // How many threads you want

$query = $db->query("SELECT * FROM ".TABLE_PREFIX."threads ORDER BY `tid` DESC LIMIT $tlimit");
while($fetch = $db->fetch_array($query))
{
	$post = get_post($fetch['firstpost']);
	$thread_link = get_thread_link($fetch['tid']);
	echo '<a href="'.$thread_link.'">'.$fetch['subject'].'</a><br />'.$post['message'].'<br/>';
}
?>
Thanks a lot Yaldaram. So it seems MyBB relies on RAW codes to get stuff done. Any documentation/tutorials for this?
(2011-12-18, 03:02 PM)milliriba Wrote: [ -> ]So it seems MyBB relies on RAW codes to get stuff done.

Not at all, you can do this either through plugin or with core file editing. You do not even want to "echo" the code, you may use variables and then call them in the template.