(2012-06-08, 01:28 PM)BleepyEvans Wrote: Im lookng to have a seperate page for the latest X amount of threads.
Ive seen many threads about adding similar things to sidebars, portals etc but nothing for a seperate page.
Ive got this code which I found on the forum but I need the page to follow the MyBB template, aswell as use pagination etc.
<?php define("IN_MYBB", 1); require_once("./global.php"); // Change this if needed $tlimit = 5; // 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"; } ?>
Anyone got any idea what needs to be done?
Thanks
Easiest way would be create two new global templates one which has the information for the header, the other that has the information for the footer.
Then use this:
http://community.mybb.com/thread-100986-...#pid736497
global customheader template:
<html>
<head>
<title>{$mybb->settings[bbname]}</title>
{$headerinclude}
</head>
<body>
{$header}
<br />
global customfooter template:
{$footer}
</body>
</html>
<?php
define("IN_MYBB", 1);
require_once ('./global.php');
eval("\$header1 = \"".$templates->get("customheader")."\";");
echo $header1;
required other content
eval("\$footer1 = \"".$templates->get("customfooter")."\";");
echo $footer1;
?>
And add all your content in between required content.
Which would look like this:
<?php
define("IN_MYBB", 1);
require_once ('./global.php');
$tlimit = 5; // How many titles you want
eval("\$header1 = \"".$templates->get("customheader")."\";");
echo $header1;
echo "<table width='100%' border='0'><thead><tr><th>Latest Threads</th></tr><tbody>";
$query = $db->query("SELECT * FROM ".TABLE_PREFIX."threads ORDER BY `tid` DESC LIMIT $tlimit");
while($fetch = $db->fetch_array($query)){
echo '<tr><td><a href="./showthread.php?tid='.$fetch['tid'].'">'.$fetch['subject'].'</a></td></tr>';
}
echo "</tbody></table>";
eval("\$footer1 = \"".$templates->get("customfooter")."\";");
echo $footer1;
?>
Think that would work for what you need.
Oh and change the layout like you wish with the table in these lines:
echo "<table width='100%' border='0'><thead><tr><th>Latest Threads</th></tr><tbody>";
$query = $db->query("SELECT * FROM ".TABLE_PREFIX."threads ORDER BY `tid` DESC LIMIT $tlimit");
while($fetch = $db->fetch_array($query)){
echo '<tr><td><a href="./showthread.php?tid='.$fetch['tid'].'">'.$fetch['subject'].'</a></td></tr>';
}
echo "</tbody></table>";
Also make sure your /global.php is ./global.php