MyBB Community Forums

Full Version: Order posts by "best answer"
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Saved as MyBB Advanced topic, thanks Leefish.

(2012-06-28, 09:18 AM)Leefish Wrote: [ -> ]...try looking at how ZingaBurga's control object function makes it possible to "edit" an existing query and piggy back the query in a plugin where the query only runs in forum X. No extra queries.

Do you know where the control object function is documented? I don't see much in the XThreads thread
The control object is not that well documented, but there are at least two other plugins that use a variation on it and RateU has made several that hook into it. By looking at those you can see how it works.

Tomm's My Network uses something very similar (or it used to - not sure right now) and OmarG's Portal plugin uses one as well. Omar's is clever as it first looks for XThreads Control object and if there it uses it. If not, it recreates it.

http://community.mybb.com/thread-120327.html << Omar plugin.
Great thank you.
To all users interesting todo the same thing I'm trying to achieve, here are my progresses on this (and also, on MySupport's features!).

First of all you'll have to modify inc/plugins/mysupport.php to display the best answer's check mark to all users, but without the unmark link attached. This isn't hard.

Open mysupport.php and find on line 2176:

if($mybb->user['uid'] == $thread['uid'])
			{
				if($thread['bestanswer'] == $post['pid'])
				{
					$bestanswer_img = "mysupport_bestanswer";
					$bestanswer_alt = $lang->unbestanswer_img_alt;
					$bestanswer_title = $lang->unbestanswer_img_title;
					$bestanswer_desc = $lang->unbestanswer_img_alt;
				}
				else
				{
					$bestanswer_img = "mysupport_unbestanswer";
					$bestanswer_alt = $lang->bestanswer_img_alt;
					$bestanswer_title = $lang->bestanswer_img_title;
					$bestanswer_desc = $lang->bestanswer_img_alt;
				}
				
				eval("\$post['mysupport_bestanswer'] = \"".$templates->get('mysupport_bestanswer')."\";");
			}

This checks if user is the author of the thread, and returns the image depending on the post status: if best answer, then returns mysupport_bestanswer, if not, returns mysupport_unbestanswer, which are declared into language file.

Let's trick it to think you aren't the thread starter, and display mysupport_bestanswer only below the actual best answer, not every post.

Add after:

else { // what to display to users that aren't thread starters?
					if($thread['bestanswer'] == $post['pid'])  // if best answer, let's display the image and other stuff!
				{
					$bestanswer_img = "mysupport_bestanswer";
					$bestanswer_alt = $lang->unbestanswer_img_alt;
					$bestanswer_title = $lang->unbestanswer_img_title;
					$bestanswer_desc = $lang->unbestanswer_img_alt;
				}
					eval("\$post['mysupport_bestanswer'] = \"".$templates->get('mysupport_bestanswer_image')."\";");  // variable in postbit templates will be parsed to match another template - we need this to avoid displaying the unmark link!
			}

Add a template and call it mysupport_bestanswer_image. Put there the image you want to display to users that aren't thread starter (which will see the image you want contained into mysupport_bestanswer template).

I've used some divs and CSS classes which are a lot better than a single image IMHO. You can combine them into a single CSS sprite and manage it without editing templates.

Next step is: pick the best answer and display it right after first post!
Thanks for the update Shade. Smile
I can't manage how to do it still...
Maybe someone will find this thread and be able to help.
Pages: 1 2