Recent post/threads mod help
I im doing a mod based in this mod of Zachariah.
That will allow me to show a list of the last 10 posts and threads in the forumhome but... it dont works fine.
The code gets the last threads fine, but in the last posts only repeat the results of the threads. Here is the code:
Code:
// last XX posts + threads in UserCP by tnguy3n
global $vbulletin;
// get last XX threads
$lastthreads = $vbulletin->db->query_read("
SELECT thread.threadid, thread.lastpost, thread.title AS threadtitle, thread.forumid, thread.replycount, thread.lastposter, thread.dateline, thread.views, forum.forumid, forum.title AS forumtitle, user.userid, user.username
FROM " . TABLE_PREFIX . "thread AS thread
LEFT JOIN " . TABLE_PREFIX . "forum AS forum ON(thread.forumid = forum.forumid)
AND thread.visible = 1
ORDER BY thread.dateline DESC
LIMIT 0, 10
");
while($lastthread = $vbulletin->db->fetch_array($lastthreads))
{
$threadtitle = $lastthread['threadtitle'];
$forumtitle = $lastthread['forumtitle'];
$forumid = $lastthread['forumid'];
$dateline = vbdate($vbulletin->options['dateformat'], $lastthread['dateline']);
$replies = vb_number_format($lastthread['replycount']);
$views = vb_number_format($lastthread['views']);
$lastposter = $lastthread['lastposter'];
$lastpost = vbdate($vbulletin->options['dateformat'], $lastthread['lastpost']);
// eval('$lastthreadsbit .= "' . fetch_template('forumhome_lastthreadsbit') . '";');
eval("\$lastthreadsbit .= \"".fetch_template('forumhome_lastthreadsbit')."\";");
}
eval('$showlastthreads .= "' . fetch_template('forumhome_lastthreads') . '";');
$db->free_result($lastthreads);
// get last XX posts
$lastposts = $vbulletin->db->query_read("
SELECT thread.threadid, thread.title AS threadtitle, thread.forumid, thread.replycount, thread.postusername, thread.postuserid, thread.dateline AS threaddate, thread.views, thread.visible, post.threadid, post.username, post.userid, post.dateline AS lastpostdate, forum.forumid, forum.title AS forumtitle
FROM " . TABLE_PREFIX . "post AS post
LEFT JOIN " . TABLE_PREFIX . "thread AS thread ON(thread.threadid = post.threadid)
LEFT JOIN " . TABLE_PREFIX . "forum AS forum ON(forum.forumid = thread.forumid)
AND thread.visible = 1
GROUP BY thread.threadid
ORDER BY lastpostdate DESC
LIMIT 0, 10
");
while($lastpost = $vbulletin->db->fetch_array($lastposts))
{
$threadtitle = $lastpost['threadtitle'];
$forumtitle = $lastpost['forumtitle'];
$lastpostedate = vbdate($vbulletin->options['dateformat'], $lastpost['lastpostdate']);
$replies = vb_number_format($lastpost['replycount']);
$views = vb_number_format($lastpost['views']);
$threadby = $lastpost['postusername'];
$threaddate = vbdate($vbulletin->options['dateformat'], $lastpost['threaddate']);
eval('$lastpostsbit .= "' . fetch_template('forumhome_lastpostsbit') . '";');
}
eval('$showlastposts .= "' . fetch_template('forumhome_lastposts') . '";');
$db->free_result($lastposts);
// end last XX posts + threads in forumhome
Some issue there?
Very much thanks
bump
|