18.9. Modifying the PHP-Nuke Sections module

Figure 18-12. Administration panel: Sections.

Administration panel: Sections.

In this section we modify the PHP-Nuke Section module:

18.9.1. How to order the articles in the Sections module

Sometimes you may not be satisfied with the order of articles in the Sections module. To change it, edit the following line of the modules/Sections/index.php:

$result = sql_query("select artid, secid, title, content, counter 
from ".$prefix."_seccont where secid=$secid $querylang", $dbi);

Change it to[1]

$result = sql_query("select artid, secid, title, content, counter 
from ".$prefix."_seccont where secid=$secid $querylang ORDER BY artid DESC", $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 adding "ORDER BY artid DESC" to the SQL query string. In plain text, this means "order the results by descending article id". The "right way" would of course be to sort by time. But lacking an extra timestamp field, we make use of the fact that later articles have a higher id. Thus, sorting by descending id will give last articles first. Think of this simple trick whenever you seek a simple way to change the order of some results.

Notes

[1]

See How to sort in Sections.