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
(2012-01-02, 09:06 PM)Fábio Maia Wrote: [ -> ]It's right below it. Or am I misunderstanding you?

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

This is what I was talking about - it turns out that adding ?action=lastpost did the trick.

In the template I changes this
<a href="{$mybb->settings['bburl']}/{$thread['threadlink']}">

to this:
<a href="{$mybb->settings['bburl']}/{$thread['threadlink']}?action=lastpost">
Yes, that's fine too, but I was talking about using the {$thread['lastpostlink']} variable. Try this:

<a href="{$mybb->settings['bburl']}/{$thread['lastpostlink']}">

Does that not work?
(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}
I know this is an old topic (I came here by using Google), but I suggest we never use this code. Although it might work indeed (I haven't tested it), but the usage of eval() brings a great security risk, because eval() allows arbirtrary code to be run! I am not very good at coding PHP, but for what I've read and done so far is never use eval(), and I code some PHP for a few years now. Even PHP.net discourages the use of eval() unless you really, really, really need to. So I am hoping if there is a solution that doesn't use eval().

I've tried to search for plugins, but I can't find any plugins which adds a topic tracker on a portal page, making it more usefull.
In my theme my sidebars are located in my header template; how can I get {$latestthreads} to work in my header template?
(2012-09-27, 01:36 AM)glhowe1 Wrote: [ -> ]In my theme my sidebars are located in my header template; how can I get {$latestthreads} to work in my header template?

Do the same but instead of index.php use the header.php instead?
I know this is an older thread but wanted to ask about a tiny issue I was having. It's likely something super simple so hopefully someone can help out Smile

Using this code, the index and portal "Latest Threads" boxes are almost identical. However, text 'titles' aren't displaying fully on the index version. For example, there's no "Views:" or "Replies:" or even a last post link. Here's a picture to show it better.

[Image: latestthreads_zpsb0aebca8.png]

Any ideas how to fix it and make them look completely identical?
(2012-12-24, 05:27 PM)Kylin Wrote: [ -> ]I know this is an older thread but wanted to ask about a tiny issue I was having. It's likely something super simple so hopefully someone can help out Smile

Using this code, the index and portal "Latest Threads" boxes are almost identical. However, text 'titles' aren't displaying fully on the index version. For example, there's no "Views:" or "Replies:" or even a last post link. Here's a picture to show it better.

[Image: latestthreads_zpsb0aebca8.png]

Any ideas how to fix it and make them look completely identical?

Replace the language things in the template with the actual text. Is the easiest.. slightly sloppy fix to this. Since the portal language variables are not loaded on the index they do not display.

But for example you can see its there:

<a href="thread-7-lastpost.html"></a>

Only the language variable is not added.

Change the default code to what is posted below ( you have to change it according to how it is for you, as long as you change the {$lang->....} to the normal text ) :

Template: portal_latestthreads
<table border="0" cellspacing="{$theme['borderwidth']}" cellpadding="{$theme['tablespace']}" class="tborder">
<tr>
<td class="thead"><strong>Latest Threads</strong></td>
</tr>
{$threadlist}
</table>
<br />

Template: portal_latestthreads_thread
<tr>
<td class="{$altbg}">
<strong><a href="{$mybb->settings['bburl']}/{$thread['threadlink']}">{$thread['subject']}</a></strong>
<span class="smalltext"><br />
<a href="{$thread['lastpostlink']}">Last Post:</a> {$lastposterlink}<br />
{$lastpostdate} {$lastposttime}<br />
<strong>&raquo; </strong>Replies: {$thread['replies']}<br />
<strong>&raquo; </strong>Views: {$thread['views']}
</span>
</td>
</tr>

And if you want to do it the proper way. You could add the language strings to the index.lang.php file (Copy paste them over from the portal.lang.php )
(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}

Hi @Dennis Tsang

Pleas can you do the same code for Latest posts and forums announcement?
Thank you.
(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}

how can I add users avatar using this tutorial?
Sorry for bumping an old thread but I was just wondering how would I restrict the amount of new threads shown?
My portal shows 4 but doing this on my index page it shows 10.
Also is there a way to add the "Replies" and "Views" before the number?

Thanks
Pages: 1 2 3