DragonPrime - LoGD Resource Community
Welcome Guest
  • Good morning, Guest.
    Please log in, or register.
  • July 16, 2018, 01:51:11 AM
Home Forums News Downloads Login Register Advanced Search
* * *
DragonPrime Menu
Login
 
 
Resource Pages
Search

Pages: [1]   Go Down
  Print  
Author Topic: Sorting Comments from Newest to Earliest  (Read 4603 times)
0 Members and 1 Guest are viewing this topic.
Pffft
Guest
« on: December 04, 2004, 07:37:53 PM »

Hi everyone...
I want to sort all of my village, shades, and wherever's comments from Newest (top) to Earliest (bottom) with the comment form box located at the top instead of the bottom.  Someone at LotGD.net told me that all I have to do is chance DESC in the viewcommentary function to ASC and then get my SQL to resort the comments from Newest to Earliest.  However, I don't know how to do the SQL query to do that.  

Can someone help me with this?   Cry
Logged
Excalibur
Member
Mod God
*****
Offline Offline

Posts: 573


I'm a newbie, plz forgive me!


View Profile WWW
« Reply #1 on: December 05, 2004, 01:32:40 PM »

Not too difficult to do  Wink
Open common.php and find the function viewcommentary
Few lines lower you'll find:
Code:
 $sql = "SELECT commentary.*,
                   accounts.name,
                   accounts.login
                   ,accounts.loggedin,
                   accounts.location,
                   accounts.laston
              FROM commentary
             INNER JOIN accounts
                ON accounts.acctid = commentary.author
             WHERE section = '$section'
               AND accounts.locked=0
             ORDER BY commentid DESC
             LIMIT ".($com*$limit).",$limit";
change the:
Code:
            ORDER BY commentid DESC
to:
Code:
            ORDER BY commentid ASC
To let the comment box appear at the top of commentary you need to move these lines (it may differ from yours as I've slightly modified them for my own use):
Code:
   if ($session[user][loggedin]) {
        if ($counttoday<($limit/2) || $session['user']['superuser']>=2){
            if ($message!="X"){
                if ($talkline!="says") $tll = strlen($talkline)+11; else $tll=0;
                $estrai="karnak";
                $restorepage=$session['user']['restorepage'];
                $paragone=strstr($restorepage,$estrai);
                //print("restorepage = $restorepage   paragone = $paragone<br>");
                if ($paragone === false){
                   output("<form action=\"$REQUEST_URI\" method='POST'>`@$message`n<input name='insertcommentary[$section]' size='40' maxlength='".(200-$tll)."'><input type='hidden' name='talkline' value='$talkline'><input type='hidden' name='section' value='$section'><input type='submit' class='button' value='Aggiungi'>`n".(round($limit/2,0)-$counttoday<3?"`)(Hai ancora ".(round($limit/2,0)-$counttoday)." commenti per oggi)":"")."`0`n</form>",true);
                   addnav("",$REQUEST_URI);
                } else {
                  if ($session['user']['dio'] == 0 or $session['user']['dio'] == 2){
                     output("<form action=\"$REQUEST_URI\" method='POST'>`@$message`n<input name='insertcommentary[$section]' size='40' maxlength='".(200-$tll)."'><input type='hidden' name='talkline' value='$talkline'><input type='hidden' name='section' value='$section'><input type='submit' class='button' value='Aggiungi'>`n".(round($limit/2,0)-$counttoday<3?"`)(Hai ancora ".(round($limit/2,0)-$counttoday)." commenti per oggi)":"")."`0`n</form>",true);
                     addnav("",$REQUEST_URI);
                  }else{
                      output("`@$message`n<input type='hidden' name='talkline' value='$talkline'><input type='hidden' name='section' value='$section'>`n`0`n</form>",true);
                      //addnav("",$REQUEST_URI);
                  }
                }

            }
        }else{
            output("`@$message`nSorry, hai esaurito i tuoi commenti in questa sezione per oggi.`0`n");
        }
    }
right before the SQL command seen before. Be sure to move ALL the code that is inside the parenthesis of if ($session[user][loggedin]) {[/i].

That's all  Smiley

Excalibur
« Last Edit: December 05, 2004, 01:34:33 PM by Excalibur » Logged

Spock: Random chance seems to have operated in our favor.
McCoy: In plain, non-Vulcan English, we've been lucky.
Spock: I believe I said that, Doctor.
Pffft
Guest
« Reply #2 on: December 05, 2004, 09:55:47 PM »

Thank you.  8]  I will try this when my host is online again.  8]
Logged
Excalibur
Member
Mod God
*****
Offline Offline

Posts: 573


I'm a newbie, plz forgive me!


View Profile WWW
« Reply #3 on: December 05, 2004, 10:31:35 PM »

Thank you.  8]  I will try this when my host is online again.  8]
You're welcome  Smiley
I've already tested the mod on my local server and it works as you want.
Logged

Spock: Random chance seems to have operated in our favor.
McCoy: In plain, non-Vulcan English, we've been lucky.
Spock: I believe I said that, Doctor.
Pffft
Guest
« Reply #4 on: December 08, 2004, 09:25:24 PM »

I finally had the chance to make the changes, however it doesn't work completely.  What I did was change the DESC to ASC in the viewcommentary function, then moved that tidbit so it's above all the text.  All that worked.  The part that didn't is when the list goes over its max line per page output, the newest comment goes to the previous page.

For example, if my village commentary is set to 10 lines of text, the 11th newest one will be moved to the second page, so players will never see the newest comments after the 10th one.
« Last Edit: December 08, 2004, 09:25:49 PM by Pffft » Logged
Excalibur
Member
Mod God
*****
Offline Offline

Posts: 573


I'm a newbie, plz forgive me!


View Profile WWW
« Reply #5 on: December 09, 2004, 03:14:21 AM »

Doh  Roll Eyes I didn't wrote so many comments, so I haven't noticed that problem  Embarrassed
I'll check again this evening when I'll be back home from work.
Logged

Spock: Random chance seems to have operated in our favor.
McCoy: In plain, non-Vulcan English, we've been lucky.
Spock: I believe I said that, Doctor.
Chaosmaker
Guest
« Reply #6 on: December 09, 2004, 03:29:14 AM »

Possible solution (without any guarantee - didn't test that Wink), do this instead of the DESC->ASC change:
Find: array_push($outputcomments[$sect],$out);
Replace with: array_unshift($outputcomments[$sect],$out);
Logged
Pffft
Guest
« Reply #7 on: December 11, 2004, 03:38:53 AM »

What I did was instead of changing the DESC to ASC, I followed Chaosmaker's suggestion and it worked.  Then I followed Excalibur's suggestion on how to move the comment form box above all the text, and it also worked.  Then I had to move the refresh/next/previous links above as well.  That took me a few minutes to figure out, but I managed and everything works now.  CM & Exc - thanx for the help.  8]
Logged
sixf00t4
Mod God
*****
Offline Offline

Posts: 1916



View Profile WWW
« Reply #8 on: June 29, 2005, 09:58:41 AM »

hmmm, is it possible to write a module to give the user an option to use alternate sorting?   I am thinking not...
Logged

Selekta
Guest
« Reply #9 on: June 29, 2005, 10:10:14 AM »

Sure as hell wouldnt be easy. You'd have to alter a lot of documents. Have fun setting up the comment moderation window. Smiley
Logged
Sichae
iMod God
SVN Users
Mod God
*
Offline Offline

Posts: 3458


If ya didn't get it by now... you're hopeless...


View Profile WWW
« Reply #10 on: June 29, 2005, 10:41:03 AM »

hmmm, is it possible to write a module to give the user an option to use alternate sorting?   I am thinking not...

Sixfoot, it would most definately have to be another variable passed down the viewcommentary string, and would not be a module, but a core modification. Smiley
Logged

If you didn't understand anything in the above post, don't try to attempt anything suggested.

Pages: [1]   Go Up
  Print  
 
Jump to:  


*
DragonPrime Notices
Please take the time to read the FAQ and browse the DragonPedia

Support Us
No funds raised yet this year
Your help is greatly appreciated!
Recent Topics
DragonPrime LoGD
Who's Online
28 Guests, 1 User
Sunday
Home Forums News Downloads Login Register Advanced Search