I'm doing some display of nodes and I want to sort them as I display them, doing something like this:
$somenodes = taxonomy_select_nodes($terms, 'or', 2, FALSE, 'n.title');
This lets me sort by title which is handy in listings sometimes. For example, in the hacked up menu system that I've been using everywhere, this lets me display nodes by title.
In order to do this, 2 lines in taxonomy module need to be modified:
Line 824 From:
function taxonomy_select_nodes($tids = array(), $operator = 'or', $depth = 0, $pager = TRUE) {
To:
function taxonomy_select_nodes($tids = array(), $operator = 'or', $depth = 0, $pager = TRUE, $order = 'n.sticky DESC, n.created DESC') {
(this leaves the default sort order intact)
Secondly Line 839 From
$sql = 'SELECT DISTINCT(n.nid), n.sticky, n.title, n.created FROM {node} n INNER JOIN {term_node} tn ON n.nid = tn.nid WHERE tn.tid IN ('. $str_tids .') AND n.status = 1 ORDER BY n.sticky DESC, n.created DESC');
To
$sql = 'SELECT DISTINCT(n.nid), n.sticky, n.title, n.created FROM {node} n INNER JOIN {term_node} tn ON n.nid = tn.nid WHERE tn.tid IN ('. $str_tids .') AND n.status = 1 ORDER BY ' . $order;



Post new comment