How to order the articles in the Stories Archive module

18.11.1. How to order the articles in the Stories Archive module

Sometimes you may wish a different order of articles in the Stories module. To change the article order so that the articles appear in alphabetical topic order, instead of a LIFO (last-in-first-out) order, edit the following line of the modules/Sections/index.php:

$result = sql_query("select sid, catid, title, time, comments, counter, topic, 
alanguage, score, ratings from ".$prefix."_stories order by sid DESC 
limit $min,$max", $dbi); 

Change it to (see Sorting the Stories Archive by Topic first):

$result = sql_query("select sid, catid, title, time, comments, counter, topic, 
alanguage, score, ratings from ".$prefix."_stories order by topic ASC 
limit $min,$max", $dbi); 
Tip Changing the order of results
 

This is a typical example of changing the order of results of a database selection. This was achieved by solely replacing "ORDER BY sid DESC" with "ORDER BY topic ASC" in the SQL query string. In plain text, this means "order the results by ascending topic". Whenever you are not satisfied with the order of your results, you will know that you have to add or change an ORDER BY clause to an SQL query string somewhere in your module. Of course, you will still have to find where, but hopefully there will be only a few calls to sql_query() in the code, so that, in the worst case, you could try them all and find the one that works.


Help us make a better PHP-Nuke HOWTO!

Want to contribute to this HOWTO? Have a suggestion or a solution to a problem that was not treated here? Post your comments on my PHP-Nuke Forum!

Chris Karakas, Maintainer PHP-Nuke HOWTO

 

Site Info v2.2.2

Last SeenLast Seen
Server TrafficServer Traffic
  • Total: 338,810,721
  • Today: 59,952
Server InfoServer Info
  • Oct 16, 2017
  • 05:30 pm PDT
 
 

Daily Inspiration