I just wanted to summarize the various fixes in the post - thank's to the contributors, the fixes allow the plugin to work, providing a sidebar list of "Latest Posts" on the Forum Index page.
I'm using the latest version 5.1.1 of DanielM's Plugin: "Latest Posts on sidebar"
https://community.mybb.com/mods.php?action=view&pid=291
I have it installed on version 1.8.21 of MyBB, running Apache and PHP version 7.1.14, using the default MyBB theme (with a bit of CSS modification to background colors).
If you are installing the plugin for the first time, I suggest making the changes to the
inc / plugins / latestposts.php file
BEFORE uploading and activating the plugin, that way you won't have to find all the various places to make fixes.
Please note that you should IGNORE and not touch the Settings option of Left or Right side for the position of the sidebar on the index page. The first time it installs, it modifies the
Theme Templates > Index Page Templates > index template of the theme, by replacing the "
forums" tag with 2 floating divs which hold
forums on the left at 74% width, and
sidebar on the right at 25% width... But any time you try to change the setting, it again modifies "forums" with another 2 divs... so each time it adds MORE nested divs making a mess of the index file... it's much easier to just go in and modify the index template manually...
And IF you modify the index template manually, there is where you can set which side (float right or left) and what percentage each side takes up of the width of the page's container. I removed the right and left code, and just put float:left and float:right
So here are the fixes, applicable BEFORE, or AFTER installation as indicated:
Fix 1:
Before Install >
inc/plugins/latestposts.php about line 147
Or after Install >
Global Templates > index_sidebar_post about line 4
change:
{$lang->latestposttime}
to:
{$lang->posttime}
Fix 2 only needed if fixing after Install...
Global Templates > index_sidebar_post about line 3
change:
<strong><a href="{$mybb->settings[\'bburl\']}/showthread.php?tid={$tid}">{$postname}</a></strong><br>
to:
<strong><a href="{$mybb->settings[\'bburl\']}/{$lastpostlink}">{$postname}</a></strong><br>
Fixes 3, 4, 5 are in the
inc/plugins/latestposts.php file, starting at the furthest down to make sure you find the correct line numbers...
about line 253 change (to fix the time of the latest post):
$lang->latestposttime = $lang->sprintf($lang->latestposttime, $lastposttimeago);
to:
$lang->posttime = $lang->sprintf($lang->latestposttime, $lastposttimeago);
about line 231 change (apparently to clean up SQL queries and keep from showing unapproved posts?):
$where .= " AND p.visible <> -1";
$query = $db->query("
SELECT t.*, u.username AS userusername, u.usergroup, u.displaygroup, lp.usergroup AS lastusergroup, lp.displaygroup as lastdisplaygroup, p.visible
FROM ".TABLE_PREFIX."threads t
LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=t.uid)
LEFT JOIN ".TABLE_PREFIX."users lp ON (t.lastposteruid=lp.uid)
LEFT JOIN ".TABLE_PREFIX."posts p ON (t.tid=p.tid AND replyto = 0)
WHERE 1=1 {$where}
ORDER BY t.lastpost DESC
LIMIT $threadlimit
");
to:
$where .= " AND t.visible = 1";
$query = $db->query("
SELECT t.*, u.usergroup AS lastusergroup
FROM ".TABLE_PREFIX."threads t
LEFT JOIN ".TABLE_PREFIX."users u ON (t.lastposteruid=u.uid)
WHERE 1=1 {$where}
ORDER BY t.lastpost DESC
LIMIT $threadlimit
");
around line 146 change (same as fix 2 above, if fixing file before installing the plugin):
<strong><a href="{$mybb->settings[\'bburl\']}/showthread.php?tid={$tid}">{$postname}</a></strong><br>
to:
<strong><a href="{$mybb->settings[\'bburl\']}/{$lastpostlink}">{$postname}</a></strong><br>
I wish the author had made these fixes and reposted the plugin - it's a great feature, and I have previously requested it be added as a feature to MyBB (but I don't think the request got much attention...) Until then, I hope I've documented the fixes provided by others in the thread correctly, and I hope it helps others avoid the headaches we've been through trying to make it work. Thanks again to the author(s).