The current implementation shows nodes in natural (nid) database order.

It would be nice if we could sort the nids by title.

This is complicated by the fact that the code is not currently structured in a way that will allow this to be implemented quickly.

CommentFileSizeAuthor
#3 sorting.directory.patch2.12 KBbeginner

Comments

beginner’s picture

Assigned: Unassigned » beginner

Which query is involved, in which function?

I guess there is no ORDER BY at all in the sql, but I still get a page where the listed nodes are not listed by nid (maybe because of deleted nodes).

What kind of ordering would be most natural? By title? By date published? By date updated?

I can provide a patch for this, but at this stage, I would welcome some pointers because the code is hard to follow, especially since the documention does no seem to correspond to the code.
E.g. the names of the variables, and the TYPE do not match here:

/**
 * Display a directory with all the resources that belong in it.
 *
 * @param $node
 *   An array of nodes that belong to a given term (tid)
 *
 * @param $tid
 *   An array of tids to perform an AND query on. Resources must be in all categories. OR The tid of the currently viewed resource. If filters are applied,
 this would be the filters' vocabulary terms.
 *
 * @param $no_link
 *   Don't link to the category view. This is used if your displaying all the resources in the category.
 *
 * @param $limit
 *   An integer used to only display n amount of resources instead of all resources for a category.
 *
 * @return
 *   HTML
 */
function theme_directory_display_resource_section($nodes, $term, $no_link = TRUE, $limit = 0) {

beginner’s picture

is the following issue a duplicate of this one?
http://drupal.org/node/111434

If so, a patch for it already exist at #11 http://drupal.org/node/93031#comment-224251.
I would only need to extract it from the Upgrade patch.

beginner’s picture

Version: master » 5.x-1.x-dev
StatusFileSize
new2.12 KB

Attached is the patch I am committing.

We can sort according to 4 values: sticky, created, changed and title.

In this patch, I am sorting according to what I think would be the most commonly used and logical manner to sort: first by sticky, then by date changed (i.e. by the date the node has last been edited).

Later, in another issue, I am going to propose simple improvements in the way the nodes are listed, adding the name of the author, date published and the 'updated' marker, so this way of sorting is the most logical.

If you disagree, the sorting can be easily updated (with another, simpler patch).

beginner’s picture

Title: Alpha sort nodes by title within term » Sort the nodes within term
Status: Active » Fixed

About #1 and the faulty documentation: I have committed a small patch (all in the Drupal-5 branch only), which corrects and improves a bit the documentation.

Since this issue is about sorting the nodes, and I have already committed the patch above, I set this issue as fixed.

Reopen if you want to discuss further in which way to sort.

Anonymous’s picture

Status: Fixed » Closed (fixed)