MyBB Community Forums

Full Version: Latest Posts On Index Sidebar [New Build 03-24-17]
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13
The original plugin has errors:
1.- In the right and left positions, if you change to the left you will never go back to the right.
2.- The date of the latest Post is always the same in all the latest post.

SOLUTION:
Disable and uninstall the plugin

The corrections made by a user have solved all the problems.
Go to and Install this new plugin.

https://community.mybb.com/thread-162649...pid1195131
Hi Daniel,

First, thanks for creating this. For the most part it's doing exactly what I want. The only thing I've noticed is that when I create a draft (without posting), it adds this to the sidebar as a recent post. I'm using mybb version 1.8.14. Any suggestions? I'm also a newby at anything web-related, so I might be missing an obvious solution.

Thanks,

April
Has anyone experienced this plugin using a lot of CPU usage?
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).
(2019-07-12, 03:50 AM)gimbal Wrote: [ -> ]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).

The author of this plugin has not visited MyBB.com since February 2018.

So, it's possible that the author has abandoned this plugin.

I have yet to use this plugin, but you can see if it is open source.

If this plugin is open source, then you can modify the plugin code to fit your needs without repercussions.

If you are planning to fix up the code for the plugin and release it on MyBB Extend page, then include the original author's contributions to the plugin along with your code fixes.
I try to add Thread Prefix on sidebar but not wok.
Below is the modification which i done.
Please correct me if anything wrong.

Will it work on Latest Post sidebar?
It give error on board after editing like this on lastest post sidebar plugin.

I add t.prefix as below

	$query = $db->query("
	SELECT t.*,t.prefix, u.username AS userusername, u.usergroup, u.displaygroup, lp.usergroup AS lastusergroup, lp.displaygroup as lastdisplaygroup, p.visible

One code is modified as below:
while($thread = $db->fetch_array($query)) {
		
		$thread['threadprefix'] = $threadprefix = '';
    if($thread['prefix'] != 0)
{
	$threadprefix = build_prefixes($thread['prefix']);
	if(!empty($threadprefix))
	{
		$thread['threadprefix'] = $threadprefix['displaystyle'].'&nbsp;';
	}
}
		
		$tid = $thread['tid'];
		$postname = htmlspecialchars_uni($thread['subject']);
		$lastpostlink = get_thread_link($thread['tid'], "", "lastpost");
		$lastposttimeago = my_date("relative", $thread['lastpost']);
		$lastposter = htmlspecialchars_uni($thread['lastposter']);
		$lastposteruid = $thread['lastposteruid'];


Will it work?

Thank you.
Seems like it should work, but the first edit isn't necessary.
Thanks Omar. It works after removing t.prefix which you mention that this not necessary.
+1.
Hi everyone, I am the developer of this plugin. I wasn't here for more than two years. I didn't know this plugin is so popular and still in use.
I see that there are some problems with the plugin and wonder if people are still using it. If so, please write a comment here or pm me. If people are still using it, I'll publish an update for this plugin.
Hi, regardless of you fixing the possible issues, thank you for your contribution again and we are glad to see you back around. Smile
Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13