Jump to the post that solved this thread.
Thread Rating:
  • 1 Vote(s) - 4 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Solved: 12 Years, 3 Months, 1 Week ago Seperate Latest X Threads Page
#4
Solved: 12 Years, 3 Months, 1 Week ago
(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
Jump to the post that solved this thread.


Messages In This Thread
Seperate Latest X Threads Page - by BleepyEvans - 2012-06-08, 01:28 PM
RE: Seperate Latest X Threads Page - by Vernier - 2012-06-08, 01:35 PM
RE: Seperate Latest X Threads Page - by anori - 2012-06-08, 01:47 PM
RE: Seperate Latest X Threads Page - by Leefish - 2012-06-08, 01:52 PM
RE: Seperate Latest X Threads Page - by Leefish - 2012-06-08, 02:46 PM
RE: Seperate Latest X Threads Page - by febian - 2014-01-29, 03:20 AM

Forum Jump:


Users browsing this thread: 2 Guest(s)