2011-12-18, 10:59 AM
2011-12-18, 12:03 PM
You can use portal.php to pull threads from specified forums.
2011-12-18, 12:35 PM
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.
2011-12-18, 12:41 PM
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";
}
?>
2011-12-18, 12:53 PM
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.2011-12-18, 01:10 PM
^ oh! Thank You
2011-12-18, 02:06 PM
Thanks all . 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:32 PM
(2011-12-18, 02:06 PM)milliriba Wrote: [ -> ]Thanks all . 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/>';
}
?>
2011-12-18, 03:02 PM
Thanks a lot Yaldaram. So it seems MyBB relies on RAW codes to get stuff done. Any documentation/tutorials for this?
2011-12-18, 04:31 PM
(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.