MyBB Community Forums

Full Version: Reverse order of replies to a post
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hey guys,

is there a way to reverse the order of replies to a post, to show newest reply first.



I've been searching all over google and the forum but have yet to find anything,

any help would be greatly appreciated!
You're going to need to edit showthread.php. Find:
		$query = $db->simple_select("posts p", "p.pid", "p.tid='$tid' $visible", array('order_by' => 'p.dateline', 'limit_start' => $start, 'limit' => $perpage));

Replace:
		$query = $db->simple_select("posts p", "p.pid", "p.tid='$tid' $visible", array('order_by' => 'p.dateline', 'order_dir' => 'DESC', 'limit_start' => $start, 'limit' => $perpage));

SELECT u.*, u.username AS userusername, p.*, f.*, eu.username AS editusername
			FROM ".TABLE_PREFIX."posts p
			LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=p.uid)
			LEFT JOIN ".TABLE_PREFIX."userfields f ON (f.ufid=u.uid)
			LEFT JOIN ".TABLE_PREFIX."users eu ON (eu.uid=p.edituid)
			WHERE $pids
			ORDER BY p.dateline

Replace with
SELECT u.*, u.username AS userusername, p.*, f.*, eu.username AS editusername
			FROM ".TABLE_PREFIX."posts p
			LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=p.uid)
			LEFT JOIN ".TABLE_PREFIX."userfields f ON (f.ufid=u.uid)
			LEFT JOIN ".TABLE_PREFIX."users eu ON (eu.uid=p.edituid)
			WHERE $pids
			ORDER BY p.dateline DESC

I'm not certain if that is everything or not though.
Very awesome, thank you for replying! And for taking the time to explain the solution! I will apply the method you posted on a test forum and see what happens! Again, thank you so much for your time!
I wanted to check back and know if it worked correctly for you?
(2014-10-23, 11:12 AM)dragonexpert Wrote: [ -> ]I wanted to check back and know if it worked correctly for you?

Hi, the modification is actually next on my list of to do things,
so much fun, so little time, as a wise man once said

And fore sure, I will look forward to posting update and I absolutely appreciate the help!
Thanks!
Hi Dragon,

So close, so close but the issue that arose was, it pushes the original thread topic to last comment, instead of the thread remaining on top and replies being underneath the thread, but other than that, it worked perfectly. Smile

As you see in the example pic below:

[Image: thread_topic.png]

I'm not sure there is a way to keep the thread topic on top and replies below the thread,
would it be a bother to ask your opinion, I was wondering perhaps,
do you know if there is a way to keep the thread topic above the replies?

In all regards, I appreciate your valuable time and the effort you've taken to assist me in the matter,
God bless.
If you are willing to always have the first post show at the top of the thread you can do this.

Go to this part since you have it edited:
$query = $db->query("SELECT u.*, u.username AS userusername, p.*, f.*, eu.username AS editusername
            FROM ".TABLE_PREFIX."posts p
            LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=p.uid)
            LEFT JOIN ".TABLE_PREFIX."userfields f ON (f.ufid=u.uid)
            LEFT JOIN ".TABLE_PREFIX."users eu ON (eu.uid=p.edituid)
            WHERE $pids
            ORDER BY p.dateline DESC"); 

Add this just before:
$query = $db->query("SELECT u.*, u.username AS userusername, p.*, f.*, eu.username AS editusername
            FROM ".TABLE_PREFIX."posts p
            LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=p.uid)
            LEFT JOIN ".TABLE_PREFIX."userfields f ON (f.ufid=u.uid)
            LEFT JOIN ".TABLE_PREFIX."users eu ON (eu.uid=p.edituid)
            WHERE $pids
            ORDER BY p.dateline ASC LIMIT 1");

while($post = $db->fetch_array($query))
		{
			if($thread['firstpost'] == $post['pid'] && $thread['visible'] == 0)
			{
				$post['visible'] = 0;
			}
			$posts .= build_postbit($post);
			$post = '';
		}
(2014-10-28, 01:09 PM)dragonexpert Wrote: [ -> ]If you are willing to always have the first post show at the top of the thread you can do this.

Go to this part since you have it edited:

$query = $db->query("SELECT u.*, u.username AS userusername, p.*, f.*, eu.username AS editusername
            FROM ".TABLE_PREFIX."posts p
            LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=p.uid)
            LEFT JOIN ".TABLE_PREFIX."userfields f ON (f.ufid=u.uid)
            LEFT JOIN ".TABLE_PREFIX."users eu ON (eu.uid=p.edituid)
            WHERE $pids
            ORDER BY p.dateline DESC"); 

Add this just before:

$query = $db->query("SELECT u.*, u.username AS userusername, p.*, f.*, eu.username AS editusername
            FROM ".TABLE_PREFIX."posts p
            LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=p.uid)
            LEFT JOIN ".TABLE_PREFIX."userfields f ON (f.ufid=u.uid)
            LEFT JOIN ".TABLE_PREFIX."users eu ON (eu.uid=p.edituid)
            WHERE $pids
            ORDER BY p.dateline ASC LIMIT 1");

while($post = $db->fetch_array($query))
 {
 if($thread['firstpost'] == $post['pid'] && $thread['visible'] == 0)
 {
 $post['visible'] = 0;
 }
 $posts .= build_postbit($post);
 $post = '';
 }

Hi and thanks Dragon, I really appreciate your time in this matter, and for all the help you have given me, and for baring with me, I'm learning the system of the forum code so I also appreciate your patience and understanding, Again, thanks!
Your insight is priceless!
the posted code doesn't work...

it show only the first post of the current page...not the realy firstpost of the thread
Does anyone have the correct code? I'm just a beginner you know (trying to add custom forum icons so far).
I know it's an old thread, but perhaps someone could share the code and the tips how to make the top voted comments appear the first.
Edit: trying to get on/off icons working as well


online dissertation writer coding for US schools