MyBB Community Forums

Full Version: Lastest Forum Activity
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3
Hi, i want to show the lastest 10 post or threads under my sidebar but i tryed to follow this: http://community.mybb.com/thread-35598.html

And even this: {$latestthreads}

And dont work, my fórum is Fórum de Informática and i want to insert it under the sidebar at the first position, i want the last 10 threads or topics that has activity in the fórum, please help me.

Thanks.
Give this a try (make copies of the files before you change them as backup):

In index.php, find:
$plugins->run_hooks("index_start");
After that, add:
// get forums user cannot view
$unviewable = get_unviewable_forums(true);
if($unviewable)
{
        $unviewwhere = " AND fid NOT IN ($unviewable)";
}

        $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, 10"
        );
        while($thread = $db->fetch_array($query))
        {
                $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")."\";");
        }

And in your index template add
{$latestthreads}
Thanks Dennis Tsang, gonna try Toungue
Worked, can i only remove the Time, number of replys and views?
What will this do for query count? I'm looking for a lite alternative to prostats.
(2011-12-29, 04:29 AM)GhostMaster Wrote: [ -> ]Thanks Dennis Tsang, gonna try Toungue
Worked, can i only remove the Time, number of replys and views?
It uses the same templates as the portal for the latest threads, so you can change it in Portal Templates, portal_latestthreads_thread - remove what you don't need.

(2011-12-29, 04:56 AM)Monaco Wrote: [ -> ]What will this do for query count? I'm looking for a lite alternative to prostats.

1 query per page view of whichever page you put the code on (in the above case, the index page).
Perfect Dennis Tsang , thank you very much man.

Best Regards.
Dennis, would you happen to know how I could show the thread title without it shortening...?
Remove this from the code you added to index.php:

if(my_strlen($thread['subject']) > 25)
{
	$thread['subject'] = my_substr($thread['subject'], 0, 25) . "...";
}

Also I'm trying to get the last post link to work - it there something like {$thread['threadlink']} but for the lats post link? (?action=lastpost)

Thanks- this is saving me 30 queries! +Rep inbound
It's right below it. Or am I misunderstanding you?

$thread['lastpostlink'] = get_thread_link($thread['tid'], 0, "lastpost");
Pages: 1 2 3