MyBB Community Forums

Full Version: change order of shouts
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I was just wondering if I could some help here, hopefully from MusicalMidget, since this is your mod!

I've changed the order of the shouts so that the newest appears first and now need to have the code rewritten so that each of the pages will also have the newest listed first. I found the code that needs to be rewritten.

if($page == $total_pages)
            {
                $start = 0;
                $limit = $count - (($total_pages - 1) * $perpage);
            }
            else
            {
                $limit = $perpage;
                
                if($page == 1)
                {
                    $start = $count - $limit;
                }
                else
                {
                    $start = $count - ($limit * $page);
                }
            } 

Can anyone take a whack at this? I tried myself but I'm not good enough at this. Thanks in advance! Big Grin

I have tried the following, which will put them in the right order but will only show the first and last page of shouts. Will be a problem when/if I get 3 or more pages! Sad

if($page == 1)
                {
                 $start = 0;
                 $limit = $perpage;
                }
                else
                    {
                 $start = $count - $perpage;
                 $limit = $perpage;
                    }
                    if($start < 0)
                       {
                    $limit = $count;
                        } 
Just to clarify, what have you already modified from the original file?

Pagination often confuses the hell out of me, but I'll see what I can do to get this working how you want it to, once I know we're working from the same manual modifications.
The first bit of code I posted is your orginal code from the root file of your plugin for version 1.2.x...the second bit of code is what I changed it to!  Just needs to be tweaked somehow, and I don't know how to do it!  Michael suggested the change with your 1.1.x version, but it doesn't work completely right with the 1.2.x version.  I'm using the edited version, since it does put the shouts in the right order (newest first) but will only show the first and last pages.  Not a problem currently, as I only have about 7 shouts on my site, but it will be a problem if there are 3 or more pages, since the middle pages won't show with the edited code.

Also, I did alter the following line in your plugin, to actually reverse the order of the shouts (the only thing I added was DESC near the end):

// Start getting shouts!
			$query = $db->query("
				SELECT s.*, s.username AS shout_username, u.username, u.usergroup, u.displaygroup
				FROM ".TABLE_PREFIX."shouts s
				LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=s.uid)
				ORDER BY s.dateline
				DESC LIMIT $start, $limit
			");



Hope that helps and also hope you can "fix" it!  Big Grin
Hey! Have you had a chance to take a look at it yet? Big Grin No rush...just didn't want you to forget about me!
I'm afraid I've had so much uni work to do recently that I haven't managed to come up with a solution to this yet. I'll do my best as soon as I can however.