2016-07-07, 03:17 AM
Hey, not sure if this is the right place exactly. If it's not can a staff member please move it, thanks.
So what I'm trying to do is grab the latest posted threads to display in my sidebar.
I stole the code from portal.php:-
and have placed it in a new php file "latest.php".
In the template file I'm put <?php include 'latest.php';?> and that's pretty much the limits of my php knowledge.
How can I make it display the thread name, author, date/time of post and how many replies it has.
Thanks,
.xer0n.
So what I'm trying to do is grab the latest posted threads to display in my sidebar.
I stole the code from portal.php:-
$latestthreads = '';
// Latest forum discussions
if($mybb->settings['portal_showdiscussions'] != 0 && $mybb->settings['portal_showdiscussionsnum'] && $mybb->settings['portal_excludediscussion'] != -1)
{
$altbg = alt_trow();
$threadlist = '';
$excludeforums = '';
if(!empty($mybb->settings['portal_excludediscussion']))
{
$excludeforums = "AND t.fid NOT IN ({$mybb->settings['portal_excludediscussion']})";
}
$query = $db->query("
SELECT t.tid, t.fid, t.uid, t.lastpost, t.lastposteruid, t.lastposter, t.subject, t.replies, t.views, u.username
FROM ".TABLE_PREFIX."threads t
LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=t.uid)
WHERE 1=1 {$excludeforums}{$tunviewwhere} AND t.visible='1' AND t.closed NOT LIKE 'moved|%'
ORDER BY t.lastpost DESC
LIMIT 0, ".$mybb->settings['portal_showdiscussionsnum']
);
while($thread = $db->fetch_array($query))
{
$forumpermissions[$thread['fid']] = forum_permissions($thread['fid']);
// Make sure we can view this thread
if(isset($forumpermissions[$thread['fid']]['canonlyviewownthreads']) && $forumpermissions[$thread['fid']]['canonlyviewownthreads'] == 1 && $thread['uid'] != $mybb->user['uid'])
{
continue;
}
$lastpostdate = my_date('relative', $thread['lastpost']);
$thread['replies'] = my_number_format($thread['replies']);
$thread['views'] = my_number_format($thread['views']);
// Don't link to guest's profiles (they have no profile).
if($thread['lastposteruid'] == 0)
{
$lastposterlink = $thread['lastposter'];
}
else
{
$lastposterlink = build_profile_link($thread['lastposter'], $thread['lastposteruid']);
}
if(my_strlen($thread['subject']) > 25)
{
$thread['subject'] = my_substr($thread['subject'], 0, 25) . "...";
}
$thread['subject'] = htmlspecialchars_uni($parser->parse_badwords($thread['subject']));
$thread['threadlink'] = get_thread_link($thread['tid']);
$thread['lastpostlink'] = get_thread_link($thread['tid'], 0, "lastpost");
$thread['forumlink'] = get_forum_link($thread['fid']);
$thread['forumname'] = $forum_cache[$thread['fid']]['name'];
eval("\$threadlist .= \"".$templates->get("portal_latestthreads_thread")."\";");
$altbg = alt_trow();
}
if($threadlist)
{
// Show the table only if there are threads
eval("\$latestthreads = \"".$templates->get("portal_latestthreads")."\";");
}
}
and have placed it in a new php file "latest.php".
In the template file I'm put <?php include 'latest.php';?> and that's pretty much the limits of my php knowledge.
How can I make it display the thread name, author, date/time of post and how many replies it has.
Thanks,
.xer0n.