18.11. Modifying the PHP-Nuke Stories Archive module

Figure 18-14. Administration panel: Add story.

Administration panel: Add story.

In this section we modify the PHP-Nuke 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); 

TipChanging 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.