Jump to the post that solved this thread.
Thread Rating:
  • 2 Vote(s) - 3 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Solved: 9 Years, 9 Months, 3 Weeks ago Lastest Forum Activity
#1
Solved: 9 Years, 9 Months, 3 Weeks ago
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.
#2
Solved: 9 Years, 9 Months, 3 Weeks ago
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}
Dennis Tsang
Former MyBB Team Member
Web: http://dennistt.net
#3
Solved: 9 Years, 9 Months, 3 Weeks ago
Thanks Dennis Tsang, gonna try Toungue
Worked, can i only remove the Time, number of replys and views?
#4
Solved: 9 Years, 9 Months, 3 Weeks ago
What will this do for query count? I'm looking for a lite alternative to prostats.
#5
Solved: 9 Years, 9 Months, 3 Weeks ago
(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).
Dennis Tsang
Former MyBB Team Member
Web: http://dennistt.net
#6
Solved: 9 Years, 9 Months, 3 Weeks ago
Perfect Dennis Tsang , thank you very much man.

Best Regards.
#7
Solved: 9 Years, 9 Months, 3 Weeks ago
Dennis, would you happen to know how I could show the thread title without it shortening...?
#8
Solved: 9 Years, 9 Months, 3 Weeks ago
Remove this from the code you added to index.php:

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

#9
Solved: 9 Years, 9 Months, 3 Weeks ago
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
#10
Solved: 9 Years, 9 Months, 3 Weeks ago
It's right below it. Or am I misunderstanding you?

$thread['lastpostlink'] = get_thread_link($thread['tid'], 0, "lastpost");
Jump to the post that solved this thread.


Forum Jump:


Users browsing this thread: 1 Guest(s)