MyBB Community Forums
Lastest Forum Activity - Printable Version

+- MyBB Community Forums (https://community.mybb.com)
+-- Forum: Community Archive (https://community.mybb.com/forum-106.html)
+--- Forum: Archived Forums (https://community.mybb.com/forum-143.html)
+---- Forum: Archived Development and Support (https://community.mybb.com/forum-155.html)
+----- Forum: MyBB 1.6 (https://community.mybb.com/forum-138.html)
+------ Forum: 1.6 General Support (https://community.mybb.com/forum-127.html)
+------ Thread: Lastest Forum Activity (/thread-110658.html)

Pages: 1 2 3


Lastest Forum Activity - GhostMaster - 2011-12-28

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.


RE: Lastest Forum Activity - Dennis Tsang - 2011-12-29

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}



RE: Lastest Forum Activity - GhostMaster - 2011-12-29

Thanks Dennis Tsang, gonna try Toungue
Worked, can i only remove the Time, number of replys and views?


RE: Lastest Forum Activity - Monaco - 2011-12-29

What will this do for query count? I'm looking for a lite alternative to prostats.


RE: Lastest Forum Activity - Dennis Tsang - 2011-12-29

(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).


RE: Lastest Forum Activity - GhostMaster - 2011-12-29

Perfect Dennis Tsang , thank you very much man.

Best Regards.


RE: Lastest Forum Activity - Monaco - 2012-01-02

Dennis, would you happen to know how I could show the thread title without it shortening...?


RE: Lastest Forum Activity - faviouz - 2012-01-02

Remove this from the code you added to index.php:

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




RE: Lastest Forum Activity - Monaco - 2012-01-02

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


RE: Lastest Forum Activity - faviouz - 2012-01-02

It's right below it. Or am I misunderstanding you?

$thread['lastpostlink'] = get_thread_link($thread['tid'], 0, "lastpost");