MyBB Community Forums

Full Version: Displaying latest threads globally in Sidebox / Sidebar?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I'm trying to place latest threads from portal globally on footer template. Obviously {$latestthreads} won't work so how could I go about generating the table list of latest threads global by placing on the footer template?

My current code:
 <div class="tborder">
  <div class="thead"><strong>{$lang->forumbit_forum}&nbsp;{$lang->toplinks_portal}<strong>
  </div>
  <div class="tcat cell-padding">{$lang->latest_threads}</div>
  <div class="trow1 cell-padding" align="center">
<!--Latest Threads go here -->
  </div>
 </div>

I tried pasting the following where <!--Latest Threads go here --> is
<table width="100%" cellspacing="0" cellpadding="{$theme['tablespace']}" border="0" align="center">
<tr><td valign="top" width="300">
{$latestthreads}
</td></tr>
</table>

But that was a no go.

Help would be much appreciated, thank you.

Edit:
I found these which may be helpful but
(2012-05-01, 07:13 PM)Yaldaram Wrote: [ -> ]AdminCP > Templates > Your theme's templates > Portal Templates > portal_announcement > and search for;
<td class="thead"><strong>{$icon} <a href="{$mybb->settings['bburl']}/{$announcement['threadlink']}">{$announcement['subject']}</a></strong></td>
and Change it into;
<td class="thead"><strong>{$icon} <a href="{$mybb->settings['bburl']}/{$announcement['threadlink']}&amp;action=lastpost">{$announcement['subject']}</a></strong></td>
(2012-03-14, 01:32 AM)cwindham Wrote: [ -> ]<?php
define("IN_MYBB", 1);
require_once("./global.php"); // Change this if needed
$tlimit = 5; // How many titles you want

$query = $db->query("SELECT * FROM ".TABLE_PREFIX."threads ORDER BY tid DESC LIMIT $tlimit");
while($fetch = $db->fetch_array($query)){
echo '<a href="./showthread.php?tid='.$fetch['tid'].'">'.$fetch['subject'].'</a><br />' . "\n";
}
?>
(2011-12-29, 03:11 AM)Dennis Tsang Wrote: [ -> ]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}

But I'm wanting to put the latest threads in a sidebox which is located in the footer template ... so I'm not yet sure how to proceed?
Bump. Still looking for some advice. Smile
I am working on a similar track. I want to create a sidebar using template adjustments.

At the moment I am using Sidebox by Nayar. He has latest threads as one of his display options. So it should be possible to look at his code and infer how this is done. In some way or another he copies the detail from the portal page contents.

If you haven't beaten me to it, I may have a look myself in a day or two and work it out.
thanks, yea I haven't found a solution so I simply just removed the box I was going to use for portal feed.