In this section we modify the PHP-Nuke Section module:
How to order the articles in the Sections module (Section 18.9.1).
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); |
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 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. |
[1] |