MyBB Community Forums

Full Version: Latest Threads, the post ID
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
So I have managed to get the latest threads on the portal page and the index page. But how can I make it so the link to the thread is for the person under Last Post.

There is probably some mybb variable for this. Like $thread[something]

Ive seen it working here. Nice side boxs there.

 <?php
// Latest forum discussions
if($mybb->settings['portal_showdiscussions'] != 0 && $mybb->settings['portal_showdiscussionsnum'])
{
    $altbg = alt_trow();
    $threadlist = '';
    $query = $db->query("
        SELECT t.*, u.username
        FROM ".TABLE_PREFIX."threads t
        LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=t.uid)
        WHERE 1=1 $unviewwhere 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($forumpermissions[$thread['fid']]['canview'] == 0 || $forumpermissions[$thread['fid']]['canviewthreads'] == 0 || $forumpermissions[$thread['fid']]['canonlyviewownthreads'] == 1 && $thread['uid'] != $mybb->user['uid'])
        {
            continue;
        }
        
        $lastpostdate = my_date($mybb->settings['dateformat'], $thread['lastpost']);
        $lastposttime = my_date($mybb->settings['timeformat'], $thread['lastpost']);
        // 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");
        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")."\";");
    }
} 
       ?>
       {$latestthreads}

Also does anyone know where a DEMO is for the mybb 1.8 that is being worked on? Or would I have to go install it myself to see? :o
If your thread ID was something like

http://www.test-test.co.uk/showthread.php?tid=3418

adding on:

http://www.test-test.co.uk/showthread.php?tid=3418&action=lastpost

would give you last posts. My site does it too.
Nvm it updates it automatically.

Trying to look for a latest posts type of thing. I'll have to settle with that for now though. Thanks anyway saved me some searching lols.